Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: How do you use userscripts?
28 points by quibono on March 6, 2024 | hide | past | favorite | 18 comments
I'd like to see use cases for userscripts, anything interesting or helpful. I see them as better at customising the web experience compared to browser extensions.


I manage my userscripts via Violentmonkey. I have about 6 active scripts:

- https://github.com/mnghsn/google-search-sidebar

- https://github.com/Zren/ResizeYoutubePlayerToWindowSize/

- https://greasyfork.org/en/scripts/457219-disable-youtube-aut...

- https://web.archive.org/web/20190216022504/https://greasyfor...

- https://github.com/zerodytrash/Simple-YouTube-Age-Restrictio...

- "Red scrolling indicator": marks unread vs read scroll position on page-down

- "Bkmks Instant": custom script to turn bkmks.com search box into instant filter.


If you’re using uBlock Origin (and you should be), it’s easy to declutter web pages by removing unwanted elements from the DOM.

I recently discovered that it can go even further in improving the user experience: it can also be used to modify most (if not all) styles on a web page. For a good description and example use case (a “dark mode” skin for Hacker News), see https://darekkay.com/blog/ublock-website-themes/


This doesn't work for many sites that use randomly generated class names and IDs. For example, it's really difficult to trim all the cruft and junk from Twitter's web interface without an userscript. With the script though it's trivial and you can also filter the feed to remove ads, suggestions, posts liked by some random people, etc.


I only modify a small number of sites that I regularly visit and so far I’ve only once come across a site with random class names and IDs (I’m guessing that’s done as a way to defeat what we’re talking about). If I remember correctly, I got around the random name problem by removing the parent element which had a defined name.

I don’t visit Twitter and certainly never tried to do anything as sophisticated as what you’re describing (though it sounds like other users on this page would benefit from your userscript). I just make the sites that I regularly visit that bit easier on the eye without spending too much effort on modifying styles (I also haven’t done web development in the last 10-15 years so delving into scripts and the DOM wouldn’t be my forté).


The popular modern css and react style frameworks use dynamically generated ids and classes so it’s not necessarily to prevent userscripts but it does make it harder to use them.


I personally will use Bookmarklets rather than Userscripts to fulfill the same purpose. Bookmarklets work even in locked-down browsers including Edge (bookmarks bar, not favorites sidebar).

The one I use most often is modelled after a similar one - after you fill out a web form you can capture your entries and restore them with a single click:

https://github.com/mossrich/Bookmarklets/blob/master/Bookmar...


Capturing and restoring form entries is something that probably would be useful as an actual browser extension (or a built-in feature to some browser), to add a menu or a keyboard command to be able to specify file names to save and recall form data.


I created my own extension for Firefox to revert Slack’s design overhaul.

https://addons.mozilla.org/en-US/firefox/addon/slackrevert/

That has just stopped working as legacy frontend components have been removed.

You could restore the old UX with some CSS hacking but ain’t nobody got time for that.


For many uses (especially those related to specific web sites, web apps, services, etc), they are better at customizing the web experience compared to browser extensions, but for some uses it isn't.

One use I used it for is to be able to view files on GitHub without needing to load all of the scripts from GitHub (which are much larger than mine). This works without any additional network connections, because the data is included in the HTML file.

On some web pages, I use userscripts to add accesskey attributes.

Sometimes, I will fix bugs on web pages by adding user scripts.

I find document.evaluate very useful in many of these cases and many other scripts I have written.

However, for many web pages, I find user CSS is useful and scripts do not need to be added. (Sometimes, I add both.)


I only use userscripts for MusicBrainz: https://github.com/ROpdebee/mb-userscripts

It massively speeds up the process of adding new data, along with a-tisket.


I use one to clip coupons automatically. The store my wife and I get most of our groceries from issues a ton of coupons, and wants you to click them individually.

I have some RSI issues so manual was a non starter.


I use Stylus to override design choice that don't work for me. Generally things like colors, fonts and hard-coded page widths. Sometimes I'll use Tampermonkey to alter content a bit.

Here is one I use to improve my experience on HN.

https://pastebin.com/JQY4cXfU


I can't deal with dates unless they include day of week. I wrote a very simple script (basically a regex) to add a letter indicating the day.

Also fun for changing website themes, extracting streams to files, augmenting games. Violentmonkey is my tool of choice for managing and live editing them.


I have a list of domains/keywords that I use to suppress articles on Google/Hacker News/RSS feeds. It's mostly sites with ad blocker blockers, and the rest are a mix of politicians, internet celebrities, and news-like infotainment products.


In Firefox I use them to customize HN. For example font sizes and text colors.


I wrote a couple userscripts for myself at work that put the information I usually care about from job logs on gitlab right at the top of the page.


Some userscripts I wish existed:

- open discord thread in new tab (with ctrl-click)

- mark YouTube video as already watched with less than 5 clicks


a script for filtering posts on HN based on keywords with a toggle button, a script for holding down control to mass click "not interested" on youtube videos on hover (or alt for mass "do not recommend channel") and a script for some small reddit fixes




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: