2

I want to load an external library (jQuery) into my .user.js script, to modify the CSS of an existing site. Now i am using $script to load external libraries, but it doesn't work.

On the other hand it would be also good to load external CSS files to modify the page, but I don't know how to do that. How can I modify the CSS easily with .user.js? How can I load external JS libraries?

This is my userscript at pastebin.com.


UPDATE:

I want to write a script or load a CSS which automatically modify the page look.

I tried to load the jQuery library with $script micro library but it doesn't work, because Chrome disables AJAX communication in the .user.js.

2
  • Are you talking about greasemonkey or chrome extension? Commented May 20, 2011 at 15:28
  • this is a chrome version of greasemonkey user scripts Commented May 20, 2011 at 15:30

2 Answers 2

3

If you don't mind taking Chrome Extension route then all problems you describing can be solved very easily without any extra coding, just with manifest file:

{
  "name": "My extension",
  ...
  "content_scripts": [
    {
      "matches": ["http://www.google.com/*"],
      "css": ["mystyles.css"],
      "js": ["jquery.js", "myscript.js"]
    }
  ],
  ...
}

It will automatically inject jquery and css along with your script to domains you specified.

Sign up to request clarification or add additional context in comments.

Comments

0

Not sure from the way the question is written, but if the only thing you want is the ability to apply jQuery to any page you happen to be looking at (so you could then change some CSS via the jQuery commands on the console), you could do that with the jQuerify bookmarklet instead of a userscript.

http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet

Of course you could also just directly modify the CSS from the console, no JS required.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.