Tampermonkey脚本无法自动更新,附脚本头部配置信息
Troubleshooting Tampermonkey Auto-Update Failures
Hey there! Let's break down why your Tampermonkey script isn't auto-updating. First, let's start with the script header you shared—notice the incomplete @grant directive at the end? That's a common culprit. Here's your formatted header for reference:
// ==UserScript== // @name Test script // @description testing auto-update // @namespace http://tampermonkey.net/ // @author newbie // @version 1.0.0 // @updateURL https://github.com/mygithubaccount/test/raw/master/test.user.js // @downloadURL https://github.com/mygithubaccount/test/raw/master/test.user.js // @match http://awebsite.com/* // @run-at document-end // @grant GM_getResourceText // @grant GM_addStyle // @grant GM_xmlhttpRequest // @grant G... <!-- This line is truncated and invalid --> // ==/UserScript==
Here are the key fixes and checks to get auto-updates working:
- Fix the incomplete
@grantline: Tampermonkey will skip update checks if it encounters invalid metadata. Either finish writing the full grant name (e.g.,GM_setValueif that's what you intended) or delete the truncated line entirely if it's a typo. - Ensure version numbering is correct: Tampermonkey only updates to scripts with a higher version number than the one installed. If your GitHub-hosted script still uses
1.0.0, increment it (e.g.,1.0.1) to trigger the update. - Validate your update URLs manually: Copy the
@updateURLinto your browser and confirm it loads the raw script file without errors (no 404s or permission blocks). Double-check that the repo path and filename are spelled correctly. - Check Tampermonkey's update settings: Open Tampermonkey's dashboard, go to Settings, and verify:
- The Auto-update interval isn't set to "Never"
- Check for updates is enabled
- Your browser's privacy settings aren't blocking requests to the update source (disable strict ad-blockers or third-party request blockers temporarily to test)
- Trigger a manual update first: Sometimes the auto-update system needs a kickstart. In Tampermonkey's script list, click the update icon next to your "Test script" to pull the latest version manually. Once this works, auto-updates should run on your configured interval.
内容的提问来源于stack exchange,提问作者newbie




