Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Using the (default) scratchpad editor leaves confusing "run" menu items #1771

cathalgarvey opened this Issue · 11 comments

4 participants


Recently started using Greasemonkey, and am really enjoying it already. So far, almost everything works fine for me; metadata is correctly parsed to get @includes, @name, @description, etc.

I have yet to use or try @require, but I have discovered that @grant appears not to work. Below is some example code. Removing all @grant statements doesn't make auto-inference work, so I have been so far unable to use any GM_ functions.

I'm using Greasemonkey 1.10 on IceWeasel, a rebranded form of Firefox, version 20:

Compatibility should not be an issue; the changes made to IceWeasel are minimal and all other extensions and features of Greasemonkey work well..


// ==UserScript==
// @name testgrants
// @namespace
// @description Testing whether or why "@grant" statements are not working in GM1.10 in IceWeasel 20.
// @include http://*
// @include https://*
// @version 1
// @grant GM_log
// @grant GM_xmlhttpRequest
// ==/UserScript==

// First error message below is with this log statement uncommented;
// recommented to demonstrate bug with GM_xmlhttpRequest
//GM_log("Making xhr request to get final location of ''");

url: "",
method: "HEAD",
synchronous: true,
onload: function(response) {
var final;

return final = response.finalUrl;


GM_log("Final url: " + final);
Exception: GM_log is not defined

Exception: GM_xmlhttpRequest is not defined


Update: Have installed Firefox 22 to test whether it's IceWeasel-specific, and it appears not to be.


Your script gives me this error:

Sun Jul 21 2013 16:35:56
Error: final is not defined
Source file: file:///C:/Users/user/AppData/Roaming/Mozilla/Firefox/Profiles/abs4ddqs.default/gm_scripts/fa/fa.user.js
Line: 29

This works for me:

  url: "",
  method: "HEAD",
  synchronous: true,
  onload: function(response) {
    try { 
      GM_log("Final url: " + response.finalUrl);
    } catch(ex) {
      GM_log('http data from ' + url + ' could not be parsed: ' + ex);

Oh, I just saw the Scratchpad-Errors.
As far as I know you can't use GM_* in Scratchpad.


Do not pick "run" in scratchpad unless your script is @grant none and has no side effects. Which basically means: do not pick "run" in scratchpad. Like any other editor, just save and reload the page.

I worried a bit about this early on. I suppose we'll have to hide those menu options when you're editing a user script to avoid confusion.


Quite right about the scratchpad issue, sorry. In my innocence I thought GM was launching scratchpad with some background hack to enable testing with "run".

However, despite now having GM_log and GM_xmlhttpRequest appear successfully in my code, GM_log still does not work (GM-xhr works fine!).

Here's the code I've written for Bandcamp: You can see at the outset that I detect GM_log and test it, but proceed with using console.log. To date I have never seen GM_log output, which was part of my original confusion in this issue: I'd been using GM_log to test whether GM_xmlhttpRequest was being detected, and its output!

To clarify prior to FAQs: I have modified the appropriate about:config settings as directed in the wiki to make GM_log function correctly, and while I do have firebug installed I have also been looking in the "normal" log.

Should I open a new issue with this, considering that I've narrowed down my problem considerably? For the record, this issue is affecting me with FF22 as well as Iceweasel 20. GM 1.1 in both cases, I think.


Derp, never linked to referred-to code:


I've taken this part of the script, and it's working fine with and without the @grant:

log = console.log;

log("Beginning ffbandcamp script.");

if (typeof GM_log !== "undefined" && GM_log !== null) {
  log("Found GM_log.");
  GM_log("This is from GM_log.");
} else {
  console.log("GM_log not found!");


Whatever the cause of your problem is, it's not in GM or the script.


It's worth leaving this issue open to track what happens when selecting the "run" scratchpad commands. I've thought about improving that in the past, and this confirms that it's valuable. Creating a separate issue to track whether/how GM_log is broken is valuable.


OK, new issue opened. Thanks for help here!

@arantius arantius closed this in 8fba26b

In removing the menu items that are nonsensical to a new user, the thing that the scratch pad is useful for is gone. If you use an external editor with out a syntax checker the scratch pad inspect is the first thing to use to show you your missing parameters or miss typed or incorrectly capitalized words.I just updated grease and now have to go back to the previous version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.