重复的greasemonkey脚本不起作用 - 莫名其妙
这实在是太离奇了。 我是 Greasemonkey 的新手,但我从 userscripts.org 下载了一个脚本,它工作得很好。然后,我使用 GM 菜单中的“新用户脚本”创建了该脚本的副本,然后将原始脚本粘贴到新脚本中。然后我禁用旧脚本并启用新脚本,但新脚本不起作用。
This is just too bizarre.
I'm new to Greasemonkey, but I downloaded a script from userscripts.org and it works fine. I then created a duplicate of that script using 'New User Script' from the GM menu and then pasted the original script into the new script. I then disable the old script and enable the new script and the new script doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您“将原始脚本粘贴到新脚本中”而没有进行任何编辑?
一些可能出错的事情:
新脚本应该有一个不同的名称 - 否则脚本安装可能会损坏。
脚本标头中是否有
@require
行?如果是这样,那么就知道仅在纯安装期间才会获取必要的资源,并且在使用“新用户脚本”菜单时此机制不起作用。要解决此问题:
将新脚本文件保存到一个方便的文件夹中,例如
C:\Work\YourScript.user.js
。不要使用 Windows 临时文件夹,因为 GM 安装在那里有问题。在 Greasemonkey 的“管理用户脚本”对话框中,卸载新脚本(以及任何潜在的名称冲突)。
在浏览器中,使用文件->打开文件并浏览到您的脚本(EG
C:\Work\YourScript.user。 js
)并打开它。应该会弹出 Greasemonkey 安装对话框。安装脚本。现在应该正确获取并保存所需的资源。您可以通过查看脚本安装文件夹来检查这一点——该文件夹类似于:
Windows 系统上的 C:\Documents and Settings\{Win 用户名}\Application Data\Mozilla\Firefox\Profiles\{Random string}.default\gm_scripts\YourScript\
。确保“包含的页面”如您所想。您可以在 Greasemonkey 的“管理用户脚本”对话框中进行检查。
仔细检查脚本编辑。在 Greasemonkey 的“管理用户脚本”对话框中,按编辑按钮并检查代码。
如果所有其他方法均失败,请在此处粘贴完整的、未经编辑的脚本代码 - 可能存在语法和/或代码错误,我们可以帮助您解决。包含代码始终是一个好主意。
You "pasted the original script into the new script" without any edits?
Some things that can go wrong:
The new script should have a different name -- other wise the script installation(s) could get corrupted.
Does the script have
@require
line(s) in the header? If so, then know that the necessary resources are only fetched during a pure install and this mechanism does not work when using the "New User Script" menu.To resolve this:
Save the new script file to a handy folder, perhaps,
C:\Work\YourScript.user.js
. Do not use the windows temp folder as GM install is buggy there.In Greasemonkey's "Manage User Scripts" dialog, Uninstall the new script (and any potential name-conflicts).
In the browser, use File->Open File and browser to your script (EG
C:\Work\YourScript.user.js
) and open it. The Greasemonkey Install dialog should pop up.Install the script. The required resources should now be fetched and saved properly. You can check this by looking in the scripts install folder -- which will be something like:
C:\Documents and Settings\{Win Username}\Application Data\Mozilla\Firefox\Profiles\{Random string}.default\gm_scripts\YourScript\
on a windows system.Make sure the "Included Pages" are what you think they are. You can check this in Greasemonkey's "Manage User Scripts" dialog.
Double check the script edits. In Greasemonkey's "Manage User Scripts" dialog, press the Edit button and inspect the code.
If all else fails, paste the full, unedited, script code here -- there's probably a syntax and/or code error we can help you with. Including the code is always a good idea.
您可能没有为新脚本的运行设置任何 URL。
当您选择“新用户脚本”时,其中一个框会标记为“包括(每行一个)”,这是 FireFox 将为其激活此脚本的 URL 列表。尽管脚本本身也列出了这些包含行,但它们仅在安装时才会合并到浏览器的设置中,而不是在您编辑脚本时合并到浏览器的设置中。
去查看脚本中的 @include 行,并将它们添加到“管理用户脚本”页面的“包含的页面”部分,您很可能会开始看到一些操作。
You probably didn't set up any URLs for the new script to work on.
When you select "New User Script", one of the boxes is labeled "Includes (one per line)", which is a list of the URLs for which FireFox will activate this script. Although the script itself also lists these include lines, they are incorporated into the browser's settings only at install time, not as you edit the script.
Go and look at the @include lines in your script and add them to the "Included Pages" section of the "Manage User Scripts" page and you will most likely start to see some action.