0

I'm trying to install the basic userscript from http://pastebin.com/9CXXYYBX. I open the page with extensions list in Chrome, drag&drop my extension (copied from the pastebin link above) there and accept the permissions. So, because of the line // @include http://userscripts.org/* the userscript should run only on the userscripts.org, but it doesn't.

I have Chrome 27 so as I know the userscripts should work without Greasemonkey installed.

What could be wrong and how to check if the userscripts are working (how to debug them so)?

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
static
  • 8,126
  • 15
  • 63
  • 89
  • The next question is different, but the answers are identical. I suggest to read http://stackoverflow.com/a/11773654/938089. – Rob W Oct 10 '13 at 18:10

1 Answers1

4

The question is not clear. Are you having trouble installing the script, or running it, or just what it reports.

Anyway, that script works fine for me.

To install it:

  1. Download the file from pastebin to your local machine.
  2. Rename the file. It comes from pastebin named crossvrowser_userscript_pattern.txt (sic), but userscripts must end in .user.js. So, rename the file to crossbrowser_userscript_pattern.user.js.
  3. Install crossbrowser_userscript_pattern.user.js by dragging it to the extension page, per this question and answers.


Permission report:

Chrome will report that the userscript can operate on all web sites, but Chrome lies about scripts that use @include. It's not a problem here.


Running the script:

After installing that script, it runs just as expected. When going to a page on userscripts.org, the script alerts, "Hello from the userscript," just like it should.


If the script doesn't run:

Go to the extensions page (chrome://extensions/), does the script show up? You should see something like:

Script installed


Then when you visit a suitable page you will see the alert:

Script's alert



You can also open Chrome's console (CtrlShiftI) and switch to the userscript's scope:

Switch to script scope

Note that the id (pfnbaeafniclcjhfkndoploalomdmgkc) is the same as that listed on the extensions page.


You can then view the script source live, add breakpoints and debug it by following the directions in this answer.


Debugging OP's script in action

Community
  • 1
  • 1
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • I do all the same you described. I have problems only with running user scripts. So the last point you mentioned is not working for me: if I go to the userscripts.org there is no alert at all. Should it alert on each page I visit, if I will remove the @include line? – static Oct 10 '13 at 22:40
  • Yes, if you remove the `@include` (not recommended!) **and reinstall the script**, then it will alert on each page. See the updated answer for more. – Brock Adams Oct 11 '13 at 00:37
  • sorry, had no time before. thank you very much for the edit! I will try at this next days (I read the edit, and I think I lost some steps you mentioned above, but I need to try and check) – static Oct 20 '13 at 17:57