1

I have old userscripts with jQuery that work fine in Firefox 16, but stopped working with the Firefox 17 release.

So, I was using version 16.0.2 until today when I tried to upgrade to 18 and the same problem persists. First, I thought that could be Greasemonkey and tried 1.6 version and the Scriptish add-on without success. So I tried to update jQuery version and no solution. It's not one script it's all of them with any jQuery code. Also no errors on console is reported.

Anybody does know what's going on?

Some errors reported by firebug console:

o.attachEvent("on"+e, h);

from:

window.addListener=function(o, e, h){
try{
o.attachEvent("on"+e, h);
}catch(a){
o.addEventListener(e, h, false);
}
} 

Another error on another script

GM_addStyle ( (<><![CDATA[

from:

GM_addStyle ( (<><![CDATA[
    #dtl {
        position:           absolute;
        top:                0;
        right:              0;      
    }
    #dtl iframe {
        width:              950;
        height:             680;
        border:             none;
    }

]]></>).toString () );
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
Commentator
  • 640
  • 1
  • 6
  • 22
  • you're up for some debugging :) narrow it down must not be big deal (it's not all jquery scripts it's only all your jquery scripst) & check out what was deprecated since jquery 1.8 since you've upgraded, there were lots of change – mikakun Jan 10 '13 at 21:41
  • You mean, if I downgrade my jQuery my "old code" can work? If "Yes", so why the firefox version affects the funcionality of the script? – Commentator Jan 10 '13 at 21:58
  • no i don't know, all my jquery code is fine since ff upgrade... so maybe it's greasemonkey did you test the same script inside a webpage (not through greasemonkey)... narrow down ! – mikakun Jan 10 '13 at 22:09
  • I've tested on greasemonkey 1.4 , 1.5 and 1.6 with Firefox 17.0.1 Also scriptish, which I'm using right now. Firefox 15, 16 works normally all of them. Firefox 17 and 18 does not. Every jquery code fails. – Commentator Jan 10 '13 at 22:14

1 Answers1

2

jQuery and Greasemonkey work fine in Firefox 17 and 18 (as long as you keep the sandbox active); that is not the problem.

The only major thing that changed with FF 17, that affected a lot of Greasemonkey scripts, is that Firefox dropped support for E4X.

With E4X, we could use CDATA to great effect making robust, multiline strings, like so:

GM_addStyle ( (<><![CDATA[
    #someNodeID {
        position:           fixed;
        top:                0;
        right:              0;
    }
]]></>).toString () );


But, now that E4X is no longer supported, we must refactor every bit of code that used CDATA, to using the javascript string escape (\), like so:

GM_addStyle ( '                         \
    #someNodeID {                       \
        position:           fixed;      \
        top:                0;          \
        right:              0;          \
    }                                   \
' );


When using that escape, you must pay extra attention to how you mix ' and " quotes.

Community
  • 1
  • 1
Brock Adams
  • 90,639
  • 22
  • 233
  • 295
  • Thank you Brock. What a waste of time and patience its gonna be, check and change every script. Happily for me, I believe changing GM_addStyle its gonna solve the problem in all of them. The one with the o.attachEvent("on"+e, h); error, was solved fixing the GM_addStyle too. – Commentator Jan 11 '13 at 05:57
  • It's not that hard if you have a good editor and know macros. I changed 51 of my scripts in a couple of hours. – Brock Adams Jan 11 '13 at 06:44