Home » Questions » Computers [ Ask a new question ]

How to get Firefox Greasemonkey script to use a local cascading stylesheet?

How to get Firefox Greasemonkey script to use a local cascading stylesheet?

What's the correct syntax to link to a CSS file in the same directory as a Greasemonkey JavaScript? I've tried the following but it doesn't work:

Asked by: Guest | Views: 345
Total answers/comments: 1
bert [Entry]

"Try this!

function addStyleSheet(style){
var getHead = document.getElementsByTagName(""HEAD"")[0];
var cssNode = window.document.c­reateElement( 'style' );
var elementStyle= getHead.appendChild(cssNode)
elementStyle.innerHTML = style;
return elementStyle;
}

addStyleSheet('@import ""example.css"";');

Note: example.css must live in the same directory as your user script for this example to work.

Reference - > DiveIntoGreaseMonkey"