--- a/WebBrowser/Tools/Scripts.py Sat Mar 12 17:02:04 2016 +0100 +++ b/WebBrowser/Tools/Scripts.py Sat Mar 12 20:05:01 2016 +0100 @@ -376,6 +376,26 @@ data = data.replace("'", "\\'") return source.format(data) + +def setCss(css): + """ + Function generating a script to set a given CSS style sheet. + + @param css style sheet + @type str + @return script to set the style sheet + @rtype str + """ + source = """ + (function() {{ + var css = document.createElement('style'); + css.setAttribute('type', 'text/css'); + css.appendChild(document.createTextNode('{0}')); + document.getElementsByTagName('head')[0].appendChild(css); + }})()""" + style = css.replace("'", "\\'").replace("\n", "\\n") + return source.format(style) + ########################################################################### ## scripts below are specific for eric ###########################################################################