Greasemonkey @grant not working anymore?

I have the following Greasemonkey script that tries to read the text of a resource:

// ==UserScript==
// @name        Test
// @namespace   test
// @version     1
// @grant       GM_getResourceText
// @resource    testresource http://stackoverflow.com/
// ==/UserScript==

var text = GM_getResourceText('testresource');

      

I tried something like this a couple of weeks ago and it worked. Now when I run this, GM_getResourceText cannot be found:

/ *
Exception: ReferenceError: GM_getResourceText not defined
@ Scratchpad / 7: 9: 5
* /

I have Greasemonkey 3.1 on Firefox 37.0.2. Does anyone have another problem and / or know what is wrong?

+3


source to share


1 answer


This code shouldn't indicate the error and GM_getResourceText()

still works fine for me on Firefox 37.0.2, Greasemonkey 3.1.

Make sure you are editing and saving the correct copy of the script. See How do I edit a script I'm working on?

When you look at the browser console, this code should contain errors like:

: Returned component failure code: 0x805e0006 [nsIWebNavigation.loadURI] browser.js: 10592: 0
TypeError: aDefault - undefined

Strictly speaking, this is a bug in Greasemonkey's code.

However, this is also not how it is commonly used @resource

. Usually you just download a specific file and a static one . @resource

intended for CSS files, images, XML, etc ... NOT a constantly changing application route.




If you really want a snapshot of such a site as a resource, save the page ( /fooobar.com / ... in your example) in the same folder as yours *.user.js

with the extension .htm

(very important) and @resource

.

So this script works just fine:

// ==UserScript==
// @name        _Test
// @include     http://YOUR_SERVER.COM/YOUR_PATH/*
// @grant       GM_getResourceText
// @resource    testresource Stack_Overflow.htm
// ==/UserScript==

var text = GM_getResourceText ('testresource');
console.log (text);

      

after you saved /fooobar.com / ... as Stack_Overflow.htm

in your script install directory.

+2


source







All Articles