My Greasemonkey script won't install

微笑、不失礼 提交于 2019-12-11 17:55:23

问题


I'm going to write a small Greasemonkey script.
Here is my test code:

// ==UserScript==
// @name test
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @namespace brak
// @description test
// @include http://forum.php.pl/*
// ==/UserScript==

$(document).ready(function(){
alert("OK");
});

But it doesn't work.

I tried downloading some random script from userscripts.org and it worked when I installed it from the website. But, when I put the source code into script.js file and then clicked "Add a new script" - it did not.

Please help.


回答1:


when I put the source code into script.js file and then clicked "Add a new script" - it did not.

The filename must end with .user.js. So rename your test file to test.user.js or something. Then you will be able to install it.




回答2:


You can try changing

// @include <a href="http://forum.php.pl/*" target="_blank">http://forum.php.pl/*</a>

To:

// @include http://forum.php.pl/*


来源:https://stackoverflow.com/questions/9976157/my-greasemonkey-script-wont-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!