问题
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