StylishThemes / StackOverflow-Dark

📚 Dark theme for Stack Overflow & most Stack Exchange network sites
https://github.com/StylishThemes/StackOverflow-Dark/raw/master/stackoverflow-dark.user.css
Other
688 stars 43 forks source link

@include tags cause TamperMonkey to slow down #80

Open MagicLegend opened 7 years ago

MagicLegend commented 7 years ago

Hi all,

I've created this issue on the Tampermonkey forums. After a bit of digging I found that the regex used in the @include tags are the issue. I've solved it by removing the regex from the tags; resulting in this:

// @include https://*stackoverflow.com/* // @include https://*stackexchange.com/* // @include https://*serverfault.com/* // @include https://*superuser.com/* // @include https://*stackapps.com/* // @include https://*mathoverflow.net/* // @include https://*askubuntu.com/*

This fixes the issue described at the TM forum, but I believe it would also react to fakestackoverflow.com. Any good solutions for this?

~ML

Mottie commented 7 years ago

Hi @MagicLegend!

If I understand correctly, you're installing the Stackoverflow-dark style from userstyles.org as a userscript? The css wrapping @-moz-document does include regexp, but only to target and ignore other specific stackoverflow subdomains. If you only want advice on how to fix the above @includes then I would try the following (essentially remove the first * from the url):

// @include https://stackoverflow.com/*
// @include https://stackexchange.com/*
// @include https://serverfault.com/*
// @include https://superuser.com/*
// @include https://stackapps.com/*
// @include https://mathoverflow.net/*
// @include https://askubuntu.com/*
// @exclude  https://www.stackexchange.com/*
// @exclude  https://area51.stackexchange.com/*
// @exclude  https://gaming.stackexchange.com/*

Or, are you asking us to fix the @-moz-document rules?

MagicLegend commented 7 years ago

If I remove the first * the subdomains won't be included :) So chat.stackoverflow.com doesn't work.

I am indeed using it as a userscript given that I don't really need something else to keep track of it, I can do that myself just fine :)

I'm not exactly sure what the issue is there (see the forum post I linked to); I hoped you might have had an idea on how to fix it permanently :)

Mottie commented 7 years ago

Oh, then you'll need to add subdomains as well...

// @include https://stackoverflow.com/*
// @include https://*.stackoverflow.com/*
// ...

Make sure to include the period (.) after the asterisk, or will will target fakestackoverflow.com.

I don't have any control over userstyles.org and how to creates a userscript, but we might be able to clean up some of the @-moz-document definitions.

MagicLegend commented 7 years ago

Oh yeah, derp. Just add two include's for the subdomains. Stupid that I didn't think of that myself lol.

Oh, hmm... Where should I post this issue then?

Mottie commented 7 years ago

Issue about what? Fixing the userstyle?... If you mean adjusting the @-moz-document definitions, I'll have to put that on my to-do list for now, and the issue here is adequate.

MagicLegend commented 7 years ago

The issue is that the regex used in the userscript is slowing down Tampermonkey in Chrome so much that some sites (for me it was a google search most of the time, but I've had it on every page I visited a few times) won't load at all. As noted by me, removing the regex from the @include tags fixes this issue.

MagicLegend commented 7 years ago

I see where your confusion is coming from; I'm still on an older version of the script which didn't use the @-moz-document.

I'll update my script, and see if the issue will be resolved :)

MagicLegend commented 7 years ago

Ay, learnt something today. @-moz-document isn't supported (currently) in Chrome. My knowledge (and google searches) can't find a better solution than to add the //@include tags to the script.

The userscript version found on userstyles.org doesn't appear to work in Tampermonkey either. When adding the //@include tags it does work tho.

Mottie commented 7 years ago

Yeah, userstyles.org & Stylish were bought by another group and they made a few changes but now they are severely neglecting both.

Are you completely opposed to using a browser extension? If you don't want to use Stylish, there is Stylus.

MagicLegend commented 7 years ago

Yes and no; I'm not opposed to it, but I don't like more clutter and another privacy policy (he said as he started looking into the privacy policy and found the best one ever). Okay, I guess there aren't any real issues with Stylus that I had with Stylish ;) I prefer having the script under my own supervision, but when I break it again (it will happen xD) I might just consider getting Stylus. Right now this is the only userstyle I use on the internet, so there is not really a point in getting another extension for it, but when the time comes I'm frustrated by Github trying to blow my eyes out I might just get it ;)

Too bad there isn't a direct script version available, I'm honestly not sure how I did it back then... The version I had was from march this year, so dunno... Thank you for your time and thoughts, I guess the issue isn't really there anymore given that the script version isn't available anywhere anymore!

Mottie commented 7 years ago

We have a userscript for GitHub, but not for Stack Exchange... I've got too much on my plate to write/support a userscript for that site as well.

MagicLegend commented 7 years ago

Not a problem mate; I just need to add the //@include tags to the script file generated by userstyles and it'll work just fine. Might be nice thing to add to the installation instructions :)

Mottie commented 7 years ago

It's a wiki page - https://github.com/StylishThemes/StackOverflow-Dark/wiki/Install - I would appreciate it if you could help out and add a section in there somewhere 😉.

MagicLegend commented 7 years ago

Ah cool! I'll take a min to write it out then :)