Created
August 31, 2025 07:49
-
-
Save ratozumbi/2e9dcc453a9e879e491550bbafbcd5f3 to your computer and use it in GitHub Desktop.
Tampermonkey javascript to change to reddit native language when coming from google searches
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name Remove URL Parameters (tl and tracking) | |
| // @namespace http://tampermonkey.net/ | |
| // @version 1.0 | |
| // @description Automatically remove ?tl= and other tracking parameters from URLs | |
| // @author You | |
| // @match *://*/* | |
| // @grant none | |
| // @run-at document-start | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| // Parameters to remove (add more as needed) | |
| const parametersToRemove = [ | |
| 'tl', // Remove ?tl= parameter | |
| 'utm_source', // Remove tracking parameters | |
| 'utm_medium', | |
| 'utm_campaign', | |
| 'utm_term', | |
| 'utm_content', | |
| 'fbclid', // Facebook click ID | |
| 'gclid', // Google click ID | |
| 'ref', // Referrer | |
| 'source' // Source tracking | |
| ]; | |
| // Function to clean URL | |
| function cleanUrl() { | |
| const currentUrl = new URL(window.location.href); | |
| let urlChanged = false; | |
| // Remove specified parameters | |
| parametersToRemove.forEach(param => { | |
| if (currentUrl.searchParams.has(param)) { | |
| currentUrl.searchParams.delete(param); | |
| urlChanged = true; | |
| } | |
| }); | |
| // If URL changed, update it and refresh page | |
| if (urlChanged) { | |
| const cleanedUrl = currentUrl.toString(); | |
| console.log('URL cleaned:', window.location.href, '->', cleanedUrl); | |
| window.location.href = cleanedUrl; // This will refresh the page | |
| } | |
| } | |
| // Clean URL on page load | |
| cleanUrl(); | |
| // Optional: Also clean URLs when they change (for SPAs) | |
| let lastUrl = window.location.href; | |
| new MutationObserver(() => { | |
| const url = window.location.href; | |
| if (url !== lastUrl) { | |
| lastUrl = url; | |
| setTimeout(cleanUrl, 100); // Small delay for SPA navigation | |
| } | |
| }).observe(document, { subtree: true, childList: true }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment