stylish
stylish copied to clipboard
stylish intermittently stops applying to links opened to new tabs in Safari 11
if i have a window that has a stylish theme in use, and then click on a link that opens in a new tab, the stylish theme intermittently is not applied, even if the green 'enabled' icon is displayed
I've tried to right click and open link in new tab on Userstyles.org website - styles works fine. Can you try?
I've been having this happen to me lately too.
Attached a screenshot. I also tried a few different styles on Reddit and they all did the same thing.
Can you open inspector and search for style
tags with apple character in id
?
I've tested one of your styles Reddit Slate Nights
- and it works fine for new tab links.
I'm not 100% what I'm looking for but I don't see anything.

SHould be something like that in the bottom of the page or inside <header>
section on top.
Ok yeah. Not seeing that.

After cmd+r

So, clicking the link (intermittent). But works after page refresh
Well, the problem is that style page doesn't work for me in any browser - https://userstyles.org/styles/118049/reddit-dark-naut-style Maybe it something wrong with style itself?
Weird. I've been using that theme for awhile.
What about this one? Works for me on reddit.com main page but then I clicked the pothole page again and it didn't work until i did cmd+r

But you can clearly see the list of styles that the regex is matching properly. Just not applying the style.
I can't debug without exact style here. Can you export your stylish settings and share it?
txt version stylish-export.json.txt
Works fine for me in latest Safari. Can you check your console for errors and try to disable any other extensions just for test.
Ok, I thought it might be NinjaKit extension but I clicked a few more links and got it to break / not work again.

Only errors I have is from my firewall blocking ads.

So, something blocked in your browser and prevent ga.js
to load. It may cause and errors in all extensions.
I've had that firewall in place a long time, years. This is only happening recently and only in Safari and I think because I updated Safari recently.
Here's a screenshot from Vivaldi with Dark Naut style.

Plus that doesn't explain why its intermittent. Same page from previous post in Safari after page refresh.
If a blocked ga.js
was the cause, it wouldn't work at all. If you really want me to disable my linux firewall I will. But I'm positive that isn't the issue. This is something recent with the Safari update.
I disabled my firewall. But it looks like Reddit is trying to load in ads that are getting blocked by the domain origin policy in Safari.
So it's just calling that https://tpc.googlesyndication.com/ domain over and over. Which is the only error, just repeats endlessly.
Going to turn my firewall back on now, wow...

I've tried to debug whats going on here and released version 2.0.3 (can be downloaded on my website https://sobolev.us/stylish) and already submitted to Apple gallery.
@350d Thanks for looking into this! I'm looking for the 2.0.3 version but I can't find it on the link you provided and I'm not seeing an update on the Apple site.
Direct link http://sobolev.us/download/stylish/stylish.zip
@350d Thanks! I downloaded that and unzipped the extension.
When I click "trust" in the Safari extensions window it doesn't seem to be showing up.
Hi @350d. Again thanks for looking into this! I was able to get the updated 2.0.3 installed. Not sure what the issue was before.
Unfortunately the random/intermittent issue with the theme style not applying is still happening in 2.0.3 and still seems to be related to the dl.href
and m.location
variables I was discussing in https://github.com/350d/stylish/pull/36.

The theme I am testing with is here; https://userstyles.org/styles/123493/reddit-modified-dark-carbon
Also this appears to only happen if you are logged into Reddit and I can duplicate the issue fairly easily when browsing https://www.reddit.com/new/
And I am using/clicking the "comment" link to duplicate this.
The links look like this that are causing the issue. https://www.reddit.com/r/formula1/comments/78bi1b/question_about_mex_gp_how_do_you_get_from/?utm_content=comments&utm_medium=new&utm_source=reddit&utm_name=frontpage
In my tests your style is always on page and looks like this is a css issue. I've tried to move this style to external css file and include it in Safari Settings - Advanced - Style Sheet and get this page layout:

Same result I have with style enabled via Stylish:

Maybe subreddit styles overrides custom css in this case?
You have to be logged in and you have go to https://www.reddit.com/prefs/ preferences > display options > uncheck "allow subreddits to show custom themes"
.
More importantly I was only able to reproduce the issue when logged in. When logged out, it seems to apply just fine with messed up styling ofc.
Again, it has to do with dl.href
and m.location
not matching each other. The inject
simply doesn't happen. It is definitely this line of code that is preventing the injection from taking place when I was debugging the extension. They do not match at times and the inject does not take place due to m.location
containing ?args
and dl.href
is not including those arguments.
https://github.com/350d/stylish/blob/master/stylish.safariextension/assets/script.js#L108
I was hoping the PR I opened would help shed some light on the issue and maybe we can come up with a better way to fix the problem.
Regardless, I can reproduce it pretty easily on reddit after a few clicks to the comment sections. Sometimes it takes 1 click others 5-7. It all depends if that m.location
variable is including the href arguments on that specific click or not. I was unable to determine why m.location
is sometimes including them or if dl.href
should include them but is not.
@k3mist m.location is a copy of d.href sended back to injected script from global script without any modification. it can't be different. The only possible chanсe is if address was changed in realtime after ping was happened from injected script and before pong was received from global script. I can try to sign every ping/pong sessions with some unique hash to avoid collisions and if your right - it will help. On that page you send me - you have few reddit iframes with the same domain name in src. Looks like you tried to debug few instances of injected script same time.
I have not looked at global.js
. I was only on focusing on where the actual injection takes place.
This is a gist of the changes I made in script.js
to debug it; https://gist.github.com/k3mist/8752754c09af19e3efbec0c1427ce28e
Here's a better screenshot debugging with the script.js
from the gist.