stylish icon indicating copy to clipboard operation
stylish copied to clipboard

stylish intermittently stops applying to links opened to new tabs in Safari 11

Open libbies opened this issue 7 years ago • 35 comments

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

libbies avatar Sep 21 '17 12:09 libbies

I've tried to right click and open link in new tab on Userstyles.org website - styles works fine. Can you try?

350d avatar Sep 27 '17 00:09 350d

I've been having this happen to me lately too.

k3mist avatar Oct 19 '17 19:10 k3mist

Attached a screenshot. I also tried a few different styles on Reddit and they all did the same thing.

screen shot 2017-10-19 at 3 49 56 pm

k3mist avatar Oct 19 '17 19:10 k3mist

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.

350d avatar Oct 19 '17 19:10 350d

I'm not 100% what I'm looking for but I don't see anything.

screen shot 2017-10-19 at 3 55 50 pm

k3mist avatar Oct 19 '17 19:10 k3mist

SHould be something like that in the bottom of the page or inside <header> section on top. screenshot 2017-10-19 15 58 54

350d avatar Oct 19 '17 20:10 350d

Ok yeah. Not seeing that.

screen shot 2017-10-19 at 4 02 35 pm

After cmd+r

screen shot 2017-10-19 at 4 02 50 pm

k3mist avatar Oct 19 '17 20:10 k3mist

So, clicking the link (intermittent). But works after page refresh

k3mist avatar Oct 19 '17 20:10 k3mist

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?

350d avatar Oct 19 '17 20:10 350d

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

screen shot 2017-10-19 at 4 14 30 pm

But you can clearly see the list of styles that the regex is matching properly. Just not applying the style.

k3mist avatar Oct 19 '17 20:10 k3mist

I can't debug without exact style here. Can you export your stylish settings and share it?

350d avatar Oct 19 '17 20:10 350d

lol github wont let you attach .json files. had to zip it

stylish-export.json.zip

screen shot 2017-10-19 at 4 20 39 pm

k3mist avatar Oct 19 '17 20:10 k3mist

txt version stylish-export.json.txt

k3mist avatar Oct 19 '17 20:10 k3mist

Works fine for me in latest Safari. Can you check your console for errors and try to disable any other extensions just for test.

350d avatar Oct 19 '17 20:10 350d

Ok, I thought it might be NinjaKit extension but I clicked a few more links and got it to break / not work again.

screen shot 2017-10-19 at 4 31 38 pm

k3mist avatar Oct 19 '17 20:10 k3mist

Only errors I have is from my firewall blocking ads.

screen shot 2017-10-19 at 4 35 24 pm

k3mist avatar Oct 19 '17 20:10 k3mist

So, something blocked in your browser and prevent ga.js to load. It may cause and errors in all extensions.

350d avatar Oct 19 '17 20:10 350d

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.

screen shot 2017-10-19 at 4 42 56 pm

k3mist avatar Oct 19 '17 20:10 k3mist

Plus that doesn't explain why its intermittent. Same page from previous post in Safari after page refresh.

screen shot 2017-10-19 at 4 49 28 pm

k3mist avatar Oct 19 '17 20:10 k3mist

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.

k3mist avatar Oct 19 '17 20:10 k3mist

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...

screen shot 2017-10-19 at 4 58 07 pm

k3mist avatar Oct 19 '17 21:10 k3mist

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 avatar Oct 20 '17 05:10 350d

@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.

k3mist avatar Oct 20 '17 14:10 k3mist

Direct link http://sobolev.us/download/stylish/stylish.zip

350d avatar Oct 20 '17 14:10 350d

@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.

screen shot 2017-10-20 at 10 40 25 am screen shot 2017-10-20 at 10 40 28 am

k3mist avatar Oct 20 '17 14:10 k3mist

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.

screen shot 2017-10-23 at 6 36 45 pm

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

k3mist avatar Oct 23 '17 22:10 k3mist

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:

screenshot 2017-10-23 23 56 32

Same result I have with style enabled via Stylish:

screenshot 2017-10-23 23 57 12

Maybe subreddit styles overrides custom css in this case?

350d avatar Oct 24 '17 03:10 350d

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 avatar Oct 24 '17 21:10 k3mist

@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.

350d avatar Oct 24 '17 21:10 350d

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.

screen shot 2017-10-24 at 6 08 47 pm

k3mist avatar Oct 24 '17 22:10 k3mist