0

I have a couple greasemonkey scripts enabled on Firefox 32. Turns out one of them stopped working (without me having changed anything). Upon closer inspection, it seems that plain old javascript code runs just fine while jQuery code does not.

I am referencing the jQuery library via the @require command. An endless list of posts comes up on Google mentioning that @require is buggy and doesn't refresh scripts. However, I don't find problem linked to that bug since this is not a new script.

I am unsure but both Firefox and Greasemonkey might have been updated and be causing issues.

This is a minimal test case:

// ==UserScript==
// @name        Test
// @namespace   asd
// @include     http://a.certain.website.com/*
// @version     1
// @grant       none

// ==/UserScript==
// @require       http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js

alert('Alert 1');

this.$ = this.jQuery = jQuery.noConflict(true);

$(document) .ready(function () {
    alert('Alert 2');
});

Alert 1 always comes up while the other dialog does not seem to be called ever.

Greasemonkey asked me to review the @grant command, so I just added that today. Did not work either. I also added the this.$ line and I was not successful either.

I also installed the latest version of Greasemoney (2.2). Disabled it, restarted Firefox and enabled it. No luck.

Any clues on what might have gone wrong?

wtf8_decode
  • 452
  • 6
  • 19

1 Answers1

2

Despite this not actually being a solution to the problem but rather a workaround, I decided to post this.

It seems like jQuery wasn't loading, so I went ahead and manually added a script tag. I removed the ready() callback and the script ended up looking like:

// ==UserScript==
// @name        Test
// @namespace   asd
// @include     http://some.domain.com/*
// @version     1
// @grant       none

// ==/UserScript==
var my_awesome_script = document.createElement('script');

my_awesome_script.setAttribute('src','http://url.to/jquery.js');

document.head.appendChild(my_awesome_script);

// Add jQuery code here
$('#someid').val('test');

I still have not figured out WHY this issue came up but this workaround certainly did the trick.

Community
  • 1
  • 1
wtf8_decode
  • 452
  • 6
  • 19