Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
libbies opened this issue Sep 21, 2017 · 35 comments

Comments

@libbies
Copy link

libbies commented Sep 21, 2017

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

@350d
Copy link
Owner

350d commented Sep 27, 2017

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

@k3mist
Copy link

k3mist commented Oct 19, 2017

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

@k3mist
Copy link

k3mist commented Oct 19, 2017

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

@350d
Copy link
Owner

350d commented Oct 19, 2017

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.

@k3mist
Copy link

k3mist commented Oct 19, 2017

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

@350d
Copy link
Owner

350d commented Oct 19, 2017

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

@k3mist
Copy link

k3mist commented Oct 19, 2017

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
Copy link

k3mist commented Oct 19, 2017

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

@350d
Copy link
Owner

350d commented Oct 19, 2017

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?

@k3mist
Copy link

k3mist commented Oct 19, 2017

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.

@350d
Copy link
Owner

350d commented Oct 19, 2017

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

@k3mist
Copy link

k3mist commented Oct 19, 2017

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
Copy link

k3mist commented Oct 19, 2017

txt version stylish-export.json.txt

@350d
Copy link
Owner

350d commented Oct 19, 2017

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

@k3mist
Copy link

k3mist commented Oct 19, 2017

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
Copy link

k3mist commented Oct 19, 2017

Only errors I have is from my firewall blocking ads.

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

@350d
Copy link
Owner

350d commented Oct 19, 2017

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

@k3mist
Copy link

k3mist commented Oct 19, 2017

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
Copy link

k3mist commented Oct 19, 2017

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
Copy link

k3mist commented Oct 19, 2017

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
Copy link

k3mist commented Oct 19, 2017

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

@350d
Copy link
Owner

350d commented Oct 20, 2017

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.

@k3mist
Copy link

k3mist commented Oct 20, 2017

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

@350d
Copy link
Owner

350d commented Oct 20, 2017

@k3mist
Copy link

k3mist commented Oct 20, 2017

@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
Copy link

k3mist commented Oct 23, 2017

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

@350d
Copy link
Owner

350d commented Oct 24, 2017

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?

@k3mist
Copy link

k3mist commented Oct 24, 2017

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.

@350d
Copy link
Owner

350d commented Oct 24, 2017

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

@k3mist
Copy link

k3mist commented Oct 24, 2017

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

@350d
Copy link
Owner

350d commented Oct 25, 2017

Ok, try version 2.0.4
Same link to download. I don't remember why I have this check for href, but I've updated domready, pop and push states, hash change events and disabled check for href in pong function. Let me known if something goes wrong 👍

@k3mist
Copy link

k3mist commented Oct 27, 2017

@350d Seems to be fixed with 2.0.4! Nice! Thanks for taking the time on this.

@LTsCreed
Copy link

I have same problem with firefox 57,0,2 and stylish version 3,0,1

@350d
Copy link
Owner

350d commented Feb 26, 2018

@trigger-death Better report it to Firefox version ;)

@trigger-segfault
Copy link

trigger-segfault commented Feb 26, 2018

Oh my bad. >.< Sent it to the right place and deleted the comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants