greasyfork-org / greasyfork

An online repository of user scripts.
https://greasyfork.org
GNU General Public License v3.0
1.41k stars 422 forks source link

Webhook syncing won't work #1253

Closed adamlui closed 1 month ago

adamlui commented 1 month ago

I wanted to change the (working) webhook for https://greasyfork.org/en/scripts/460805-autoclear-chatgpt-history/admin

from: https://github.com/adamlui/userscripts/raw/master/chatgpt/autoclear-chatgpt-history/autoclear-chatgpt-history.user.js to: https://github.com/adamlui/autoclear-chatgpt-history/blob/main/greasemonkey/autoclear-chatgpt-history.user.js

...so I took these steps:

  1. "Turn off syncing for this script"
  2. Added https://github.com/adamlui/autoclear-chatgpt-history/blob/main/greasemonkey/autoclear-chatgpt-history.user.js as auto-sync src
  3. "Update and sync now"

The sync occurred, as shown in script History and /users/webhook-info:

image

Then I added a webhook to https://github.com/adamlui/autoclear-chatgpt-history

image

Then I made a new push to test things out https://github.com/adamlui/autoclear-chatgpt-history/commit/9806dd7a8f838c2eecf032f361d5f01dc3a5b5d5, but the users/webhook-info page oddly still displays "Automatic syncing"

image

adamlui commented 1 month ago

The Recent Deliveries tab shows that commit was delivered, I even tried redelivering but /users/webhook-info still shows "Automatic syncing" and script History doesn't show the update (w/ description "Removed unicode from meta")

image

adamlui commented 1 month ago

Also auto-syncing stopped working too for my last update https://github.com/adamlui/autoclear-chatgpt-history/commit/c8dfaa6b5e40f7e53e774e44c0d9f927deefbdee

No matter how many times I click 'Update and sync now' it keeps insisting 'Script successfully synced, but no changes found.'

but this line on GitHub:

config.assetHostURL = config.gitHubURL.replace('github.com', 'cdn.jsdelivr.net/gh') + '@16d188e/'

...is outdated on GF:

config.assetHostURL = config.gitHubURL.replace('github.com', 'cdn.jsdelivr.net/gh') + '@d845801/'
adamlui commented 1 month ago

There was an update of a few lines few mins before this that successfully synced when clicking 'Update and sync now' though

adamlui commented 1 month ago

I just made a new update to meta https://github.com/adamlui/autoclear-chatgpt-history/commit/2eb6b211fb8b46f274a4bc6aae72cf9829cc3090 and then clicking 'Update and sync now' worked this time (also pulling in the config.assetHostURL update that didn't sync prior)

JasonBarnabe commented 1 month ago

Are you still having any problems with webhooks?

adamlui commented 1 month ago

@JasonBarnabe only this one but I will disconnect and reconnect after I eat and see if it fixes it

JasonBarnabe commented 1 month ago

Please post the request/response from the webhook.

adamlui commented 1 month ago

Sure I just updated 1min ago

Request headers:

Request URL: https://greasyfork.org/en/users/3967-adamlui/webhook
Request method: POST
Accept: */*
Content-Type: application/json
User-Agent: GitHub-Hookshot/9c82d0e
X-GitHub-Delivery: f4bcdfe8-2295-11ef-8ed5-28dc39613684
X-GitHub-Event: push
X-GitHub-Hook-ID: 477036818
X-GitHub-Hook-Installation-Target-ID: 620553193
X-GitHub-Hook-Installation-Target-Type: repository
X-Hub-Signature: sha1=32f500a48a98721ff51ed2281fd6cbc6414efa96
X-Hub-Signature-256: sha256=6837c51e83b798702620bdbd5feeb3fd5c797d7b0c5f01997904187df9b37530

Request payload:

{
  "ref": "refs/heads/main",
  "before": "d38645adf985731eccafc5f721787bc8bc13e4c8",
  "after": "8e18512d725be664bf6b8f4413cc8d2b482767c4",
  "repository": {
    "id": 620553193,
    "node_id": "R_kgDOJPzj6Q",
    "name": "autoclear-chatgpt-history",
    "full_name": "adamlui/autoclear-chatgpt-history",
    "private": false,
    "owner": {
      "name": "adamlui",
      "email": "adamlui@protonmail.com",
      "login": "adamlui",
      "id": 10906554,
      "node_id": "MDQ6VXNlcjEwOTA2NTU0",
      "avatar_url": "https://avatars.githubusercontent.com/u/10906554?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/adamlui",
      "html_url": "https://github.com/adamlui",
      "followers_url": "https://api.github.com/users/adamlui/followers",
      "following_url": "https://api.github.com/users/adamlui/following{/other_user}",
      "gists_url": "https://api.github.com/users/adamlui/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/adamlui/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/adamlui/subscriptions",
      "organizations_url": "https://api.github.com/users/adamlui/orgs",
      "repos_url": "https://api.github.com/users/adamlui/repos",
      "events_url": "https://api.github.com/users/adamlui/events{/privacy}",
      "received_events_url": "https://api.github.com/users/adamlui/received_events",
      "type": "User",
      "site_admin": false
    },
    "html_url": "https://github.com/adamlui/autoclear-chatgpt-history",
    "description": "🕶️ Adds chat auto-clear functionality to ChatGPT for more privacy",
    "fork": false,
    "url": "https://github.com/adamlui/autoclear-chatgpt-history",
    "forks_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/forks",
    "keys_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/teams",
    "hooks_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/hooks",
    "issue_events_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/issues/events{/number}",
    "events_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/events",
    "assignees_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/assignees{/user}",
    "branches_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/branches{/branch}",
    "tags_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/tags",
    "blobs_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/languages",
    "stargazers_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/stargazers",
    "contributors_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/contributors",
    "subscribers_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/subscribers",
    "subscription_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/subscription",
    "commits_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/contents/{+path}",
    "compare_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/merges",
    "archive_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/downloads",
    "issues_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/issues{/number}",
    "pulls_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/labels{/name}",
    "releases_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/releases{/id}",
    "deployments_url": "https://api.github.com/repos/adamlui/autoclear-chatgpt-history/deployments",
    "created_at": 1680044802,
    "updated_at": "2024-06-03T21:16:15Z",
    "pushed_at": 1717521291,
    "git_url": "git://github.com/adamlui/autoclear-chatgpt-history.git",
    "ssh_url": "git@github.com:adamlui/autoclear-chatgpt-history.git",
    "clone_url": "https://github.com/adamlui/autoclear-chatgpt-history.git",
    "svn_url": "https://github.com/adamlui/autoclear-chatgpt-history",
    "homepage": "https://autoclearchatgpt.com",
    "size": 2725,
    "stargazers_count": 37,
    "watchers_count": 37,
    "language": "JavaScript",
    "has_issues": true,
    "has_projects": false,
    "has_downloads": true,
    "has_wiki": false,
    "has_pages": false,
    "has_discussions": true,
    "forks_count": 7,
    "mirror_url": null,
    "archived": false,
    "disabled": false,
    "open_issues_count": 1,
    "license": {
      "key": "other",
      "name": "Other",
      "spdx_id": "NOASSERTION",
      "url": null,
      "node_id": "MDc6TGljZW5zZTA="
    },
    "allow_forking": true,
    "is_template": false,
    "web_commit_signoff_required": false,
    "topics": [
      "artificial-intelligence",
      "chat",
      "chatbot",
      "chatgpt",
      "chatgpt3",
      "gpt",
      "gpt-3",
      "gpt-4",
      "greasemonkey",
      "javascript",
      "machine-learning",
      "ml",
      "nlp",
      "openai",
      "privacy",
      "userscripts"
    ],
    "visibility": "public",
    "forks": 7,
    "open_issues": 1,
    "watchers": 37,
    "default_branch": "main",
    "stargazers": 37,
    "master_branch": "main"
  },
  "pusher": {
    "name": "adamlui",
    "email": "adamlui@protonmail.com"
  },
  "sender": {
    "login": "adamlui",
    "id": 10906554,
    "node_id": "MDQ6VXNlcjEwOTA2NTU0",
    "avatar_url": "https://avatars.githubusercontent.com/u/10906554?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/adamlui",
    "html_url": "https://github.com/adamlui",
    "followers_url": "https://api.github.com/users/adamlui/followers",
    "following_url": "https://api.github.com/users/adamlui/following{/other_user}",
    "gists_url": "https://api.github.com/users/adamlui/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/adamlui/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/adamlui/subscriptions",
    "organizations_url": "https://api.github.com/users/adamlui/orgs",
    "repos_url": "https://api.github.com/users/adamlui/repos",
    "events_url": "https://api.github.com/users/adamlui/events{/privacy}",
    "received_events_url": "https://api.github.com/users/adamlui/received_events",
    "type": "User",
    "site_admin": false
  },
  "created": false,
  "deleted": false,
  "forced": false,
  "base_ref": null,
  "compare": "https://github.com/adamlui/autoclear-chatgpt-history/compare/d38645adf985...8e18512d725b",
  "commits": [
    {
      "id": "8e18512d725be664bf6b8f4413cc8d2b482767c4",
      "tree_id": "3de2ae3abaead9619727492f76d746ea44d519e0",
      "distinct": true,
      "message": "Internationalized state words in notifications",
      "timestamp": "2024-06-04T10:14:51-07:00",
      "url": "https://github.com/adamlui/autoclear-chatgpt-history/commit/8e18512d725be664bf6b8f4413cc8d2b482767c4",
      "author": {
        "name": "Adam Lui 刘展鹏",
        "email": "adamlui@pm.me",
        "username": "adamlui"
      },
      "committer": {
        "name": "GitHub",
        "email": "noreply@github.com",
        "username": "web-flow"
      },
      "added": [

      ],
      "removed": [

      ],
      "modified": [
        "greasemonkey/autoclear-chatgpt-history.user.js"
      ]
    }
  ],
  "head_commit": {
    "id": "8e18512d725be664bf6b8f4413cc8d2b482767c4",
    "tree_id": "3de2ae3abaead9619727492f76d746ea44d519e0",
    "distinct": true,
    "message": "Internationalized state words in notifications",
    "timestamp": "2024-06-04T10:14:51-07:00",
    "url": "https://github.com/adamlui/autoclear-chatgpt-history/commit/8e18512d725be664bf6b8f4413cc8d2b482767c4",
    "author": {
      "name": "Adam Lui 刘展鹏",
      "email": "adamlui@pm.me",
      "username": "adamlui"
    },
    "committer": {
      "name": "GitHub",
      "email": "noreply@github.com",
      "username": "web-flow"
    },
    "added": [

    ],
    "removed": [

    ],
    "modified": [
      "greasemonkey/autoclear-chatgpt-history.user.js"
    ]
  }
}

Response (200) headers:

Access-Control-Allow-Origin: *
Cache-Control: max-age=0, private, must-revalidate
Content-Length: 72
Content-Type: application/json; charset=utf-8
Date: Tue, 04 Jun 2024 17:14:53 GMT
Etag: W/"82e9ff483bfef8a004c51c232a104fd0"
Referrer-Policy: strict-origin-when-cross-origin
Server: nginx/1.18.0 (Ubuntu)
Strict-Transport-Security: max-age=31536000
Vary: Accept
X-Backend-Server: archer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Request-Id: 66e34b8d-452c-4318-baa3-a7598ba639ee
X-Runtime: 0.009945
X-Xss-Protection: 0

Response body:

{"updated_scripts":[],"updated_failed":[],"message":"No scripts found."}
JasonBarnabe commented 1 month ago

The problem is that you've provided the URL https://github.com/adamlui/autoclear-chatgpt-history/blob/main/greasemonkey/autoclear-chatgpt-history.user.js, which is GitHub's HTML view of the file, rather than the raw JS URL https://github.com/adamlui/autoclear-chatgpt-history/raw/main/greasemonkey/autoclear-chatgpt-history.user.js. Using the HTML URL worked in some cases, but not for webhooks.

I've updated the code to automatically switch the URL to the raw JS URL when setting up syncing. Since yours is already set up, you just need to update the URL for it to work.

adamlui commented 1 month ago

Why not make it work for webhooks? I believe it worked in some cases because I pointed out this was beneficial in the past and you made some update (so I assumed it worked with webhooks)

JasonBarnabe commented 1 month ago

It does work now (by automatically switching to the correct URL) - that is what my code update did.

You just need to additionally update the URL because your setting existed before I made this update.

adamlui commented 1 month ago

Never mind I see you are making it work the beneficial way, but I can't find where to update URL

adamlui commented 1 month ago

There's no way to edit webhooks once created, I had to go to script page, "Turn off syncing" to get webhook to disappear from https://greasyfork.org/en/users/webhook-info, go to GitHub repo > Settings > Webhooks, delete GF webhook, confirm, Add webhook, fill in payload URL, update content-type, fill in secret, Add webhook, and even then it's unclear what is the URL it's going to try to sync with