Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

HELP - How to Use GM_addStyle and //@resource with Chrome ??

edited December 2018 in Development Firefox

I wrote an userscript to use my userstyles in a GM directly:
Userstyles / GreasyFork Enhancer Dark-Grey + Comments Numbering
It used before this library:
But it seems not working.

After reading:
How do I use CSS with Greasemonkey? ,
i fix it by using now GM_addStyle and //@resource.
It seems more simple for me.

It work, but only in Firefox.
How can i write it to adapt it for Chrome too ?

I use 2 //@resource:
Maybe it's the problem?
I am not sure if it is the good way to write it.

Here my script:
// ==UserScript==
// @name Userstyles / GreasyFork Enhancer Dark-Grey + Comments Numbering v.122
// @namespace
// @icon
// @description Custom Widescreen CSS theme for and
// @copyright 2011+, decembre (
// @license GPL version 3 or any later version;
// @version 122

// @include*
// @include*
// @include*   

// CSS1 = Userstyles - Greasy Fork Enhancer Dark-Grey  v.121
// @resource      CSS1

// CSS2 = Userstyles - GreasyFork - Forum - Comments Numbering + Permalink v.115
// @resource      CSS2

// @grant         GM_addStyle

// @grant         GM_getResourceText
// ==/UserScript==



  • Chrome doesn't support @-moz-document sections which is a nonstandard Firefox-only feature, which is why it ignores everything inside such sections. You have two options if you don't want to use an extension such as Stylus in Chrome: 1) implement URL handling yourself, parse, and apply sections dynamically on URL change, or 2) simply put everything in a plain CSS without sections and risk some CSS being applied incorrectly.

  • edited December 2018 Firefox

    Thanks for your fast reply!
    Have you some related pages or scripts example for a newbie like me ;-)

    2) simply put everything in a plain CSS without sections and risk some CSS being applied incorrectly_:
    Because it don't take care of the different namespace ?

    I have seen , but not tested, the possibility to insert a stylesheet into the header of the pages:
    It's a solution for this script and what's happens for namespaces?

    I tested too the install userstyles by script in the site and i see it does the job perfectly .

    • How it execute that?
    • It's possible to use its function for external Userstyles (like mine on Pastebin) ?
  • Namespace is not needed in Chrome in 99.9999999999% of cases.

    As for code, it does what I said above - it checks the URLs manually so yeah, you can do the same. Just find a multisection style and see how it looks as a userscript, then adapt to your code. One note though: their code is executed internally on all sites, which slows down the browser, so you need to keep your // @include entries.

  • "Just find a multisection style":
    Like this one ?
    After the transform to an userscript by the userstyles site,
    it seems working fine.

    The problem:
    I can't see the script which does this job internally in
    I find the code repository:
    Online repository of user styles.
    but not something i can adapt (i am not coder).


Sign In or Register to comment.