Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Greasemonkey script does not load external JS and CSS file

I am exactly doing what Brock Adams mentioned here but I am not being able to see alert at all. I have put all my files in same folder where user script exist but some how it is broken and I can't trace it either.

I am on Firefox version 21

like image 290
Volatil3 Avatar asked Nov 28 '22 21:11

Volatil3


1 Answers

That linked answer was from 2011, and Greasemonkey has changed a lot since then. (Note, I just now updated that answer to reflect the changes.)

Basically, you need to use @grant directives now. If you looked on Firefox's error console (CtrlShiftJ), you might have seen error messages like:

GM_addStyle is not defined

Here is a bare-bones addition of jQuery-UI to demonstrate the process:

// ==UserScript==
// @name     _YOUR_SCRIPT_NAME
// @include  http://YOUR_SERVER.COM/YOUR_PATH/*
// @require  http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require  http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js
// @resource jqUI_CSS  http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css
// @grant    GM_addStyle
// @grant    GM_getResourceText
// ==/UserScript==

var jqUI_CssSrc = GM_getResourceText ("jqUI_CSS");

GM_addStyle (jqUI_CssSrc);
like image 117
Brock Adams Avatar answered Dec 01 '22 00:12

Brock Adams