Hacker News new | ask | show | jobs
by swyx 7 hours ago
is this better than using a chrome extension? i guess people need to have tampermonkey installed and so thats a slightly higher barrier to entry? i wonder if chrome would be interested in "sherlocking" userscripts so that we can distribute non security nightmare code easier.
3 comments

In addition to the advantage of explicitly specified capabilities mentioned by others, I'd say a userscript is also much more durable and low-maintenance than a Chrome extension. This is coming from someone who's written an extension for personal use before, and had to jump through a million hoops with Chrome Dev just to give the browser permission to run my own code that I wrote myself, and that's to say nothing of the whole mess with manifest v3 as well. Throughout the entire time I've been able to happily keep using userscripts written by myself or others with 0 maintenance required.
Mostly transparency. Since this runs across pages you visit (with the sites controlled by the @include/@exclude rules at the top of the script), I like that the entire source is right there and easy to inspect before installing it.

A userscript also let me iterate quickly without dealing with extension packaging and permissions, but being able to see and tweak the code was a big part of the appeal.

Tampermonkey isn't better than using a Chrome extension, but it's less friction for a developer to build and distribute a cross browser script. If they build it as an extension, they need to target multiple browsers and get it deployed to the Firefox/Chrome web store.
If you can read JS and the user script is not huge, I think it makes a huge difference.

Apart from that, there are APIs exclusive to extensions, e.g. instrumenting client-side communication among tabs with different origins, listing all tabs, basically accessing a special API that sits on a higher-level context, and, while gating certain functionality behind user approval, and forbidding other functionality completely (at least in Manifest 3.0), extensions with the corresponding permissions can do more than a script running in the page context. They can inject these as well, though, even overriding CSP sometimes, as far as I know?

The main problem with these permissions, and WebExtension 3.0 partly was an attempt to improve this, or at least claims it: most people give a second of doubt at best when installing an extension, as long as they think it comes from a trusted source.

I love userscripts. Aren't we all using https://github.com/violentmonkey/violentmonkey now though?

thought I realize "if it works it works", https://github.com/Tampermonkey/tampermonkey

I did something similar 2 days ago with ViolentMonkey if you only want to check high-level discussion without any new tabs at all.

https://greasyfork.s3.us-east-2.amazonaws.com/sokzpb2ztmatlh... (screenshot)

https://greasyfork.org/en/scripts/588721-hacker-news-comment...

I'd improve it by counting top level comments next to items but that would slow it down. Still need to make some slight changes like closing sidebar by re-clicking orange (beyond just right-clicking sidebar.)

It's very fast and speeds up thinking overall.

Not on Safari, but I should migrate on Firefox I’ve read (some controversy).

  zip is available only if you're logged-in on GitHub site
Haven’t seen that before.
Userscripts are also less friction for the user. At least for some level of triviality.

I would say only go for extensions over userscript if you need a settings menu (or any of the APIs the sibling comment mentions).