Is Opera disabling Violentmonkey scripts?
-
A Former User last edited by
All of a sudden, one of my Violentmonkey scripts stopped working. It created a stylesheet to be used with any web page. I tried different approaches, but none have worked. What is wrong with Opera or Violentmonkey? The script was working before. Instead of creating a stylesheet on the fly, I tried loading one from my hard drive, but that does not work either. Am I screwing up, suddenly? The scripts:
// ==UserScript== // @name Content-style // @namespace Violentmonkey Scripts // @include * // @grant none // ==/UserScript== function addCss(cssString) { var newCss = document.createElement('style'); newCss.type = "text/css"; newCss.innerHTML = cssString; document.getElementsByTagName('head')[0].appendChild(newCss); console.log("appended css"); } addCss ( 'a[href^="javascript:"] { \ color: #006000 !important; background-color: #FFD8D8 !important; \ background-image: none !important; \ } \ a:visited { \ color: #AA00AA !important; \ background-color: #FFFFB0 !important; \ background-image: none !important; \ } \ a:hover { \ color: #E00000 !important; \ background-color: #A0FFFF; \ background-image: none !important; \ } \ :link[target="_blank"], :visited[target="_blank"],\ :link[target="_new"], :visited[target="_new"] { \ cursor: crosshair; \ } \ p {user-select: text !important; \ } \ div.back2top {height: auto !important; \ } \ canvas { \ border: 4px solid red!important; \ } \ ');
With the same header but attempts at 3 different sets of contents ([username} replaces the name of my account):
var cssId = 'myCss'; { var head = document.getElementsByTagName('head')[0]; var link = document.createElement('link'); link.id = cssId; link.rel = 'stylesheet'; link.type = 'text/css'; link.href = 'file:///Users/[username]/Sites/Opera%20Stuff/opcontent.css'; link.media = 'all'; head.appendChild(link); } var styles = "@import url('file:///Users/[username]/Sites/Opera%20Stuff/opcontent.css');"; var newSS=document.createElement('link'); newSS.rel='stylesheet'; newSS.href='data:text/css,'+escape(styles); document.getElementsByTagName("head")[0].appendChild(newSS); function loadcssfile(filename, filetype) { if (filetype == "css") { var fileref = document.createElement("link") fileref.setAttribute("rel", "stylesheet") fileref.setAttribute("type", "text/css") fileref.setAttribute("href", "file:///Users/[username]/Sites/Opera%20Stuff/opcontent.css") } if (typeof fileref != "undefined") document.getElementsByTagName("head")[0].appendChild(fileref) }