• Login
    • Search
    • Categories
    • Recent
    • Tags
    • Users
    • Groups
    • Rules
    • Help

    Do more on the web, with a fast and secure browser!

    Download Opera browser with:

    • built-in ad blocker
    • battery saver
    • free VPN
    Download Opera

    Is Opera disabling Violentmonkey scripts?

    Opera for Mac
    1
    1
    719
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A Former User
      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)
      }
      
      Reply Quote 0
        1 Reply Last reply
      • First post
        Last post

      Computer browsers

      • Opera for Windows
      • Opera for Mac
      • Opera for Linux
      • Opera beta version
      • Opera USB

      Mobile browsers

      • Opera for Android
      • Opera Mini
      • Opera Touch
      • Opera for basic phones

      • Add-ons
      • Opera account
      • Wallpapers
      • Opera Ads

      • Help & support
      • Opera blogs
      • Opera forums
      • Dev.Opera

      • Security
      • Privacy
      • Cookies Policy
      • EULA
      • Terms of Service

      • About Opera
      • Press info
      • Jobs
      • Investors
      • Become a partner
      • Contact us

      Follow Opera

      • Opera - Facebook
      • Opera - Twitter
      • Opera - YouTube
      • Opera - LinkedIn
      • Opera - Instagram

      © Opera Software 1995-2025