Using a userScript to remove query parameters from a website URL is very easy. This example below removes all of the unneeded extra URL junk from the Daily Mail website news articles.
// ==UserScript== // @name Remove Daily Mail UK query parameters. // @namespace http://tampermonkey.net/ // @version 0.1 // @description Removes URL query parameters from the current page. // @author John Cartwright // @match https://www.dailymail.co.uk/news/* // @icon https://www.google.com/s2/favicons?sz=64&domain=dailymail.co.uk // @grant none // ==/UserScript== (function() { 'use strict'; const cleanURL = window.location.protocol + "//" + window.location.host + window.location.pathname; if (window.location.search) { history.replaceState({}, document.title, cleanURL); } })(); |
This script checks whether there are any query parameters in the current page’s URL (window.location.search). If it finds any, it constructs a new “clean” URL without these parameters and updates your browser’s address bar using history.replaceState().
To use this script, install a browser extension like Tampermonkey for Chrome or Greasemonkey for Firefox. Then create a new userscript within the extension and paste this code into it. This is a very simple and useful example of userscripts to make a simple change on a website.
Use these rules for uBlock Origin to block annoying parts of the Youtube interface.
! 2023-06-09 https://www.youtube.com www.youtube.com###simple-box > .ytd-comments-header-renderer.style-scope www.youtube.com###menu > .ytd-watch-metadata.style-scope www.youtube.com###top-row > .ytd-watch-metadata.style-scope.item www.youtube.com###end ! 2023-06-29 https://www.youtube.com www.youtube.com###show-hide-button > .ytd-live-chat-frame.style-scope www.youtube.com###country-code |