Created
          June 24, 2025 07:30 
        
      - 
      
- 
        Save ashramwen/99a6f83d92befab929376bd34e5c84e1 to your computer and use it in GitHub Desktop. 
    Remove tracking codes
  
        
  
    
      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 tracking seeds | |
| // @namespace http://tampermonkey.net/ | |
| // @version 2025-05-20 | |
| // @description try to take over the world! | |
| // @author You | |
| // @match *://*/* | |
| // @icon https://www.google.com/s2/favicons?sz=64&domain=facebook.com | |
| // @grant none | |
| // ==/UserScript== | |
| function has(String, search) { | |
| try { | |
| if (String.indexOf(search) > -1) { | |
| return true; | |
| } | |
| } catch (err) {} | |
| return false; | |
| } | |
| /** | |
| * Removes any query parameters from the URL that match the given array of keys. | |
| * @param {string} url - The URL to clean. | |
| * @param {string[]} keys - Array of parameter names to remove. | |
| * @returns {string} - Cleaned URL. | |
| */ | |
| function removeCustomParams(url, keysGroups) { | |
| try { | |
| const u = new URL(url); | |
| keysGroups.forEach((keys) => { | |
| // Remove only if all params in keys exist | |
| if (keys.every((key) => u.searchParams.has(key))) { | |
| keys.forEach((key) => u.searchParams.delete(key)); | |
| } | |
| // If only one param in array, remove if exists | |
| if (keys.length === 1 && u.searchParams.has(keys[0])) { | |
| u.searchParams.delete(keys[0]); | |
| } | |
| }); | |
| u.search = u.searchParams.toString() ? '?' + u.searchParams.toString() : ''; | |
| return u.toString(); | |
| } catch (e) { | |
| return url; | |
| } | |
| } | |
| (function () { | |
| 'use strict'; | |
| const customParamsToRemove = [ | |
| // Remove if single parameter exists | |
| ['ref'], | |
| ['fb_action_ids'], | |
| ['fb_action_types'], | |
| ['utm_source'], | |
| ['utm_medium'], | |
| ['utm_campaign'], | |
| ['utm_term'], | |
| ['utm_content'], | |
| ['utm_id'], | |
| ['gclid'], | |
| ['fbclid'], | |
| ['igsh'], | |
| ['igshid'], | |
| ['at_link_id', 'at_ptr_name', 'at_campaign'], | |
| ['si'], | |
| // Remove only if both parameters exist | |
| ['utm_source', 'utm_medium'], | |
| ['utm_campaign', 'utm_content'], | |
| ]; | |
| // Clean the current page URL | |
| let currentURL = window.location.href; | |
| let cleanedURL = removeCustomParams(currentURL, customParamsToRemove); | |
| // If the cleaned URL is different, replace the current URL | |
| if (cleanedURL !== currentURL) { | |
| window.history.replaceState(null, '', cleanedURL); | |
| } | |
| })(); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment