59de44955ebd / twitter-to-bsky

Crosspost from Twitter/X to Bluesky and Mastodon directly in the web browser
8 stars 1 forks source link

The userscript sometimes does not load (Firefox + ViolentMonkey + Linux) #3

Closed hardpenguin closed 10 months ago

hardpenguin commented 10 months ago

Like in the description, the userscript sometimes does not load. It happens, I don't know, less than 50% of the time I load Twitter in my browser tab? What often helps (but not always) is performing a forced reload/refresh (CTRL+F5) of the tab.

The very latest stable versions of the userscript (0.11), Firefox (119.0), and ViolentMonkey (2.16.0) were used. Not sure how to debug this? Happy to follow any debugging steps if you're willing to do that together.

I believe this is the error message from the developer console:

Content Security Policy: The page's settings blocked the loading of a resource „inline” („script-src”).

Which in turn led me to the debugger output (attached). debugger_output.txt

I did some digging and I suspect this might be related (I might be wrong though, I don't know a first thing about modern web development): https://github.com/violentmonkey/violentmonkey/issues/173

hardpenguin commented 10 months ago

Hold your horses with the reply, I am testing changing the userscript @inject-into setting to "auto" in ViolentMonkey... So far so good... I'll let you know

59de44955ebd commented 10 months ago

I already had exactly the same issues with Firefox in Windows, sometimes it loads, sometimes not. What seemed to help is a forced reload (e.g. by holding the Shift-Key), but of course that's not really a solution. But this issue only occurs with Violentmonkey, not with Greasemonkey, which is why I for now use Greasemonkey in Firefox instead.

59de44955ebd commented 10 months ago

ps: a couple of days ago I had spent half a day for finding a workaround for this Violentmonkey-Firefox-CSP issue, unfortunately without success. It smells like some bug in Violentmonkey, since as mentioned it never occurs in Greasemonkey in the same browser.

59de44955ebd commented 10 months ago

pps: I forgot to mention, "@inject-into auto" would disable the ability to "hook" into Twitter's XMLHttpRequest calls, which is needed to support "Cards" in Bluesky (in Bluesky they have to be created on the client side, whereas in Mastodon the server/instance/endpoint takes care of it). But yes, if you only use Mastodon anyway, this should fix the issue.

hardpenguin commented 10 months ago

I see! Thanks for all the details. It looks like that setting fixed the issue for me. Yeah it is frustrating because some userscripts work better in Tampermonkey, other in Violentmonkey etc. (Greasemonkey is not recommended because it has not been updated in 3 years).

Feel free to close this issue if you feel this solves it, at least for now.

59de44955ebd commented 10 months ago

Oops, my bad! When I wrote "Greasemonkey" above I actually always meant "Tampermonkey" - I don't have this old Greasemonkey installed anywhere. It's just too many monkeys, that's why I got a little confused :-)

59de44955ebd commented 10 months ago

FYI, I know added this as "Known limitation" to the README and closed the issue.