My old Greasemonkey scripts do not work any more for Firefox v57 and GM v4.0

1,398 views
Skip to first unread message

Ben Stover

unread,
Nov 21, 2017, 11:17:59 AM11/21/17
to Greasemonkey Users
Today I updated Firefox to new 64bit v57 and to Greasemonkey AddOn v4.0

As far as I can see all my old scripts do not work any more.

Unfortunately I cannot figure out if the update to GM 4.0 or the update to Firefox v57 causes the trouble.

Do others have the same problems?

Or do I have to adjust something to work?

Ben




Phillip Cazzola

unread,
Nov 21, 2017, 11:00:17 PM11/21/17
to greasemonkey-users


GM 4.0 has a new API


"We've elected to make a rare backwards incompatible change."

Ben

unread,
Nov 22, 2017, 4:27:21 AM11/22/17
to greasemonkey-users
@Phillip Cazzola

thank for the comment.

However I am still confused.

I have some scripts with lots of GM_addStyle() statements.

According to webpage http://www.greasespot.net/ there is ", there is no support for GM_addStyle".
On the other side it is written: "In general these methods work like their old counterparts, but their return values are Promises"

Hmm, so when I re-write a (formerly working) script to

....
// @grant           GM.addStyle
...
GM.addStyle("#foobarid { font-size: 16px !important;");


it does still not work.

How do I have to adjust the script otherwise to be v4.0 compatible?

Ben

Anthony Lieuallen

unread,
Nov 22, 2017, 11:16:02 AM11/22/17
to greasemon...@googlegroups.com
On Wed, Nov 22, 2017 at 4:27 AM, 'Ben' via greasemonkey-users <greasemon...@googlegroups.com> wrote:
How do I have to adjust the script otherwise to be v4.0 compatible?

GM_addStyle just does DOM manipulations.  You don't need a special API for this, just add a <style> node to the document and you're done.
Message has been deleted

Phillip Cazzola

unread,
Nov 22, 2017, 11:58:14 AM11/22/17
to greasemonkey-users

Anthony created a script to bridge compatibility.  You can add this to the top of your script and it will define a GM_addStyle() function


... or you can take the part that sets the CSS styles (the variable "aCss" should contain the css text)

    let head = document.getElementsByTagName('head')[0];
    if (head) {
      let style = document.createElement('style');
      style.setAttribute('type', 'text/css');
      style.textContent = aCss;
      head.appendChild(style);
    }

Ben

unread,
Nov 23, 2017, 2:55:55 AM11/23/17
to greasemonkey-users
The @require trick works.
Thank you.

However it is only a workaround. Since I want to minimize the dependencies from external sources I wonder what the "official" way of applying CSS code in Greasemonkey v4.0 is.

Anthony Lieuallen said something about a <script> node in the original html code. But I have no access to the original web page code.

I want to modify a loaded web page afterwards with Greasemonkey. Thats perfect.

So again: How should users write GM_addStyle() instructions like the old example:

GM_addStyle("#foobar { font-size: 16px !important;");

officially in the future WITHOUT the help of bridge scripts?


Evgeniy

unread,
Nov 24, 2017, 2:26:11 AM11/24/17
to greasemonkey-users
Until something similar will be implemented in GM itself (I doubt it, reading previous Anthony opinions), you can just add this piece of code to every GM-script you maintain. No external dependencies, no @require use. And you do have access to the original page's DOM.

David C. Stevens

unread,
Nov 27, 2017, 7:52:08 PM11/27/17
to greasemonkey-users
I've had the similar issue, but every time I install a script, I have no idea where the GM script is.I'm not a programmer, and a lot what the developers are saying, is almost a foreign language. The only thing I'm able to get out of all this is that the older GM scripts no longer work with GM 4.0. Please, can anyone assist me with the new GM 4.0 scripts and where can I access the GM scripts are placed.
Thank You.

beatric...@haugensgalleri.com

unread,
Nov 28, 2017, 1:32:20 AM11/28/17
to greasemonkey-users
Does this mean that all scripts made to work with previous versions will no longer work until fixed to be compatible?  Or only SOME scripts?  If so, how do we tell the difference?  (I have minimal computer knowledge--just enough to be dangerous.  I can install scripts that other people have made, but have no clue how they actually work.)  If there is a simple fix to the header, say, I could do that.  Anything more complicated ...
Reply all
Reply to author
Forward
0 new messages