├── LICENSE ├── README.md └── TrackingTokenStripper.user.js /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Will 保哥 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TrackingTokenStripper 2 | 3 | A [Tampermonkey](https://www.tampermonkey.net/) Userscript that remove most of the annoying tracking token from URL parameters. 4 | 5 | ## Features 6 | 7 | - Strip most of the known tracking token from your URL **before** page been navigated. 8 | - The following token will be removed: 9 | - Facebook 10 | - `fbclid` 11 | - Google Analytics 12 | - `utm_source` 13 | - `utm_medium` 14 | - `utm_term` 15 | - `utm_campaign` 16 | - `utm_content` 17 | - `utm_cid` 18 | - `utm_reader` 19 | - `utm_referrer` 20 | - `utm_name` 21 | - `utm_social` 22 | - `utm_social-type` 23 | - Google Ads 24 | - `gclid` 25 | - Instagram 26 | - `igshid` 27 | - HubSpot 28 | - `_hsenc` 29 | - `_hsmi` 30 | - MailChimp 31 | - `mc_cid` 32 | - `mc_eid` 33 | - Marketo 34 | - `mkt_tok` 35 | - Yandex 36 | - `yclid` 37 | - `_openstat` 38 | 39 | ## Usage 40 | 41 | 1. Install [Tampermonkey](https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo) Chrome extension. 42 | 43 | 2. Click [this link](https://github.com/doggy8088/TrackingTokenStripper/raw/master/TrackingTokenStripper.user.js) to install Userscript. 44 | 45 | 3. Hit **Install** button in the Tampermonkey extension page. 46 | 47 | ![Tampermonkey Userscript installation](https://user-images.githubusercontent.com/88981/91120197-acc9ad00-e6c7-11ea-8f4c-2fa3526a72b7.jpg) 48 | 49 | ## Links 50 | 51 | - [Tampermonkey • Documentation](https://www.tampermonkey.net/documentation.php) 52 | - [@run-at](https://www.tampermonkey.net/documentation.php#_run_at) 53 | - [About | TrackingTokenStripper | Userscripts | OpenUserJS](https://openuserjs.org/scripts/doggy8088/TrackingTokenStripper) 54 | - [TrackingTokenStripper | Greasy Fork](https://greasyfork.org/en/scripts/409925-trackingtokenstripper) 55 | 56 | ## Related Userscripts 57 | 58 | - [chgc/CleanFBSapce: 不想看到 FB 贊助廣告的套件](https://github.com/chgc/CleanFBSapce) 59 | -------------------------------------------------------------------------------- /TrackingTokenStripper.user.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name TrackingTokenStripper 3 | // @version 1.4 4 | // @description Remove most of the annoying tracking token from URL parameters 5 | // @license MIT 6 | // @homepage https://blog.miniasp.com/ 7 | // @homepageURL https://blog.miniasp.com/ 8 | // @website https://www.facebook.com/will.fans 9 | // @source https://github.com/doggy8088/TrackingTokenStripper/raw/refs/heads/master/TrackingTokenStripper.user.js 10 | // @namespace https://github.com/doggy8088/TrackingTokenStripper 11 | // @author Will Huang 12 | // @match *://*/* 13 | // @run-at document-start 14 | // ==/UserScript== 15 | 16 | (function () { 17 | 'use strict'; 18 | 19 | const oldReplaceState = history.replaceState; 20 | history.replaceState = function replaceState() { 21 | let ret = oldReplaceState.apply(this, arguments); 22 | window.dispatchEvent(new Event('replacestate')); 23 | window.dispatchEvent(new Event('locationchange')); 24 | return ret; 25 | }; 26 | 27 | window.addEventListener('popstate', () => { 28 | window.dispatchEvent(new Event('locationchange')); 29 | }); 30 | 31 | window.addEventListener('locationchange', function () { 32 | executeActions(); 33 | }); 34 | 35 | executeActions(); 36 | 37 | let id = setInterval(executeActions, 500); 38 | 39 | setTimeout(() => { clearInterval(id); }, 2000); 40 | 41 | function executeActions() { 42 | 43 | var s = TrackingTokenStripper(location.href) 44 | // facebook 45 | .remove('fbclid') 46 | .removeByDomain('www.facebook.com', 'privacy_mutation_token') 47 | .removeByDomain('www.facebook.com', 'acontext') 48 | .removeByDomain('www.facebook.com', '__xts__[0]') 49 | .removeByDomain('www.facebook.com', 'notif_t') 50 | .removeByDomain('www.facebook.com', 'notif_id') 51 | .removeByDomain('www.facebook.com', 'notif_ids[0]') 52 | .removeByDomain('www.facebook.com', 'notif_ids[1]') 53 | .removeByDomain('www.facebook.com', 'notif_ids[2]') 54 | .removeByDomain('www.facebook.com', 'notif_ids[3]') 55 | .removeByDomain('www.facebook.com', 'ref', 'notif') 56 | .removeByDomain('www.facebook.com', 'ref=watch_permalink') 57 | 58 | // Dropbox 59 | .removeByDomain('www.dropbox.com', '_ad') 60 | .removeByDomain('www.dropbox.com', '_camp') 61 | .removeByDomain('www.dropbox.com', '_tk') 62 | 63 | // YouTube 64 | // https://youtu.be/4f-Y9G5ENPc?si=SHSu2hEdSbXGy4_Q 65 | // https://www.youtube.com/embed/4f-Y9G5ENPc?si=GQFJV_nKMXxpiQb6 66 | .removeByDomain('youtu.be', 'si') 67 | .removeByDomain('www.youtube.com', 'si') 68 | 69 | // Google Analytics 70 | // https://support.google.com/analytics/answer/1033863?hl=en 71 | .remove('utm_id') 72 | .remove('utm_source') 73 | .remove('utm_medium') 74 | .remove('utm_campaign') 75 | .remove('utm_term') 76 | .remove('utm_content') 77 | .remove('_ga') 78 | 79 | // GA - others 80 | .remove('utm_campaignid') 81 | .remove('utm_cid') 82 | .remove('utm_reader') 83 | .remove('utm_referrer') 84 | .remove('utm_name') 85 | .remove('utm_social') 86 | .remove('utm_social-type') 87 | .remove('gclid') 88 | .remove('igshid') 89 | .remove('_hsenc') 90 | .remove('_hsmi') 91 | .remove('mc_cid') 92 | .remove('mc_eid') 93 | .remove('mkt_tok') 94 | .remove('yclid') 95 | .remove('_openstat') 96 | 97 | // devblogs.microsoft.com 98 | .removeByDomain('devblogs.microsoft.com', 'utm_issue') 99 | .removeByDomain('devblogs.microsoft.com', 'utm_position') 100 | .removeByDomain('devblogs.microsoft.com', 'utm_topic') 101 | .removeByDomain('devblogs.microsoft.com', 'utm_section') 102 | .removeByDomain('devblogs.microsoft.com', 'utm_cta') 103 | .removeByDomain('devblogs.microsoft.com', 'utm_description') 104 | .removeByDomain('devblogs.microsoft.com', 'ocid') 105 | 106 | // Microsoft 107 | .remove('wt.mc_id') 108 | .removeByDomain('learn.microsoft.com', 'ocid') 109 | .removeByDomain('learn.microsoft.com', 'redirectedfrom') 110 | 111 | .removeByDomain('azure.microsoft.com', 'OCID') 112 | .removeByDomain('azure.microsoft.com', 'ef_id') 113 | 114 | .removeByDomain('www.msn.com', 'ocid') 115 | .removeByDomain('www.msn.com', 'cvid') 116 | 117 | // bilibili 118 | .removeByDomain('www.bilibili.com', 'share_source') 119 | .removeByDomain('www.bilibili.com', 'share_medium') 120 | 121 | // Others 122 | .remove('__tn__') 123 | .remove('gclsrc') 124 | .remove('itm_source') 125 | .remove('itm_medium') 126 | .remove('itm_campaign') 127 | .remove('mc') // sendgrid.com 128 | .remove('mcd') // sendgrid.com 129 | .remove('cvosrc') // sendgrid.com 130 | .remove('cr_cc') // https://blogs.microsoft.com/ 131 | 132 | .remove('sc_channel') 133 | .remove('sc_campaign') 134 | .remove('sc_geo') 135 | .remove('trk') 136 | .remove('sc_publisher') 137 | .remove('trkCampaign') 138 | .remove('sc_outcome') 139 | .remove('sc_country') 140 | 141 | .remove('__hstc') 142 | .remove('__hssc') 143 | .remove('__hsfp') 144 | .remove('_gl') 145 | 146 | // Yahoo News 147 | .remove('guce_referrer') 148 | .remove('guce_referrer_sig') 149 | 150 | .toString(); 151 | 152 | if (s && location.href !== s) { 153 | // console.log('Changing URL', s); 154 | // location.href = s; 155 | oldReplaceState.apply(history, [{}, '', s]); 156 | } 157 | 158 | function TrackingTokenStripper(url) { 159 | const parsedUrl = new URL(url); 160 | return { 161 | remove(name, value) { 162 | if (parsedUrl.searchParams.has(name)) { 163 | if (value && value === parsedUrl.searchParams.get(name)) { 164 | parsedUrl.searchParams.delete(name); 165 | } 166 | if (!value) { 167 | parsedUrl.searchParams.delete(name); 168 | } 169 | } 170 | return TrackingTokenStripper(parsedUrl.toString()); 171 | }, 172 | removeByDomain(domain, name) { 173 | if (parsedUrl.hostname.toLocaleLowerCase() === domain.toLocaleLowerCase()) { 174 | if (name.indexOf('=') >= 0) { 175 | var [key, value] = name.split("="); 176 | return this.remove(key, value); 177 | } else { 178 | return this.remove(name); 179 | } 180 | } else { 181 | return this; 182 | } 183 | }, 184 | toString() { 185 | return parsedUrl.toString(); 186 | } 187 | } 188 | } 189 | } 190 | 191 | })(); 192 | --------------------------------------------------------------------------------