1

I updated my browser, and without any warning, most of my user-scripts are broken. This is mostly because, suddenly, I cannot access properties from the page's global window objects that were defined by page scripts (native properties are available).

This prevents me from overriding functions, reading global variables etc. The stuff that people usually do with user-scripts.

The question therefore is, how can I reverse this, apart from downgrading to old Firefox?

How to access and/or change global scope from user scripts in Greasemonkey 4?

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778
  • 1
    Might be because you are using `grant none` . I ran into same issue a few weeks ago and ended up installing Tampermonkey ( as suggested in greasemonkey docs and I already use in chrome) and copy/pasted my codes into it and they work fine there. Am running Firefox developer edition – charlietfl Dec 16 '17 at 02:18
  • Also they changed (backward incompatible) the GM object https://www.greasespot.net/2017/09/greasemonkey-4-for-script-authors.html – charlietfl Dec 16 '17 at 02:27
  • @charlietfl And what should I use if not `@grant none`? – Tomáš Zato Dec 16 '17 at 02:34
  • I really don't use it enough to know. It's a bit like `require` where you have to grant which internal API's you want to use. I created a few scripts over time that worked fine using grant none and never dug into their api that much. But dropping those same scripts into TamperMonkey only took me about 1/2 hour to figure out and with no code changes – charlietfl Dec 16 '17 at 02:37
  • Also if your scripts aren't compatible they seem to be greyed out a bit when they display in the greaseMonkey dropdown list. Working ones are black font not grey – charlietfl Dec 16 '17 at 02:42
  • They work, but I cannot access any of the functions they define. Many of my userscripts are actually development tools that define functions that help me with debugging. Or they did, until greasemonkey decided to destroy everything. – Tomáš Zato Dec 16 '17 at 02:44
  • Yup ..me too. And some site customizations. But I haven't had to tweak anything since I changed – charlietfl Dec 16 '17 at 02:45
  • @charlietfl Could you elaborate? I switched to Tampermonkey but I still cannot access the global object. I tried using `unsafeWindow`, but that just causes error: `unsafeWindow is not defined` – Tomáš Zato Dec 16 '17 at 03:23
  • Using `grant none` I have no problem accessing `window` . Also on Stackoverflow I use the jQuery `$` from global as if I ran the code in console or wrote a script to insert right into this page with a script tag – charlietfl Dec 16 '17 at 03:41

0 Answers0