Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Method for Debugging Userscripts in Chrome

I've attempted to make some modifications to a userscript to enable it to work under Chrome, but when I drag it into Chrome's window in order to install it, a dialog pops up and says 'Invalid Script Header'.

I've tried to use the Developer Tools, and built-in Javascript Console, to debug any errors occurring, but nothing appears to list any information.

Console.app does not list anything meaningful, except for the same error message I already know.

[0x0-0x2d02d].com.google.Chrome: [346:1547:16686819618022:ERROR:extension_error_reporter.cc(55)] Extension error: Invalid script header.

How can I reasonably debug this error message and figure out what about the header is incorrect?

I'm using Chrome 15.0.861.0 on the dev channel, under OS 10.7 Lion.

like image 843
VxJasonxV Avatar asked Aug 28 '11 08:08

VxJasonxV


People also ask

How do I debug in Chrome?

The Chrome Web Inspector and Debugger are conveniently built-in with Chrome. You can launch it by hitting F12 while in your browser or by right clicking on a web page and selecting the Inspect menu item. The images below show a few different views that you'll see in the Chrome DevTools browser.

How do I debug a Greasemonkey script?

Open the global script debugger window via Tools → Web Developer → Browser Toolbox → Debugger (or Ctrl + Shift + Alt + I ) . Search for the name of your userscript and start debugging.


1 Answers

I finally stumbled across the answer to this question, amusingly via a Chromium Bug Report.

As it turns out, the answer to my question was in the (significantly brief) Userscript Documentation for Chrome page.

With Greasemonkey-style @include rules, it is not possible for Chrome to know for certain the domains a script will run on (because google.* can also run on google.evil.com). Because of this, Chrome just tells users that these scripts will run on all domains, which is sometimes scarier than necessary. With @match, Chrome will tell users the correct set of domains a user script will run on.

As it turns out, I had been using @match http://*musicbrainz.org in an attempt to match www.musicbrainz.org as well as musicbrainz.org, but per the quoted text, that doesn't save you from accidentally matching evilmusicbrainz.org. So, my solution was to use two lines:

@match http://*.musicbrainz.org
@match http://musicbrainz.org
like image 89
VxJasonxV Avatar answered Sep 17 '22 19:09

VxJasonxV