cssgreasemonkeytampermonkeyuserscriptsuserstyles

Conversion from CSS to UserScript


I'm trying to convert a small piece of UserStyles visual theme code into a TamperMonkey script. Until a few months ago, UserStyles.org had a feature that allowed you to do this with the click of a button. Alas, it is no longer available.

Please help me convert the following CSS code to UserScript :

/* ==UserStyle==
@name         Remove Youtube left sidebar
@description  Makes YouTube sidebar collapse
@author       fgtranime
@license      No License
==/UserStyle== */

@-moz-document domain("youtube.com") {
#guide {
    display: none;
}

ytd-app[guide-persistent-and-visible] ytd-page-manager.ytd-app {
    margin-left: 0;
}
}

p.s. I have tried using several converters found on GitHub, but none of them gives the desired result.


Solution

  • Here is a userscript based on your userStyle

    // ==UserScript==
    // @name          Remove Youtube left sidebar
    // @description   Makes YouTube sidebar collapse
    // @match         *://*.youtube.com/*
    // @version       1.0
    // @grant         GM_addStyle
    // ==/UserScript==
    
    const css = 
    `#guide {
      display: none;
    }
    
    ytd-app[guide-persistent-and-visible] ytd-page-manager.ytd-app {
      margin-left: 0;
    }`;
    
    GM_addStyle(css);