Remove tracking parameter from link

From LemonWiki共筆
Revision as of 20:59, 13 November 2022 by Planetoid (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

To remove tracking parameter from link

Bookmarklet: Remove tracking tokens from URL

javascript:(function(){function removeParameters(parms) {for (let i = 0; i < parms.length; i++) {var my_parameter = parms[i];const pattern = new RegExp(`[\?&]${my_parameter}=[^&]+`, %27gi%27);  history.replaceState && history.replaceState(  null, %27%27, location.pathname + location.search.replace(pattern, %27%27).replace(/^&/, %27?%27));}  }var parms = [%27fbclid%27, %27gclid%27, %27gclsrc%27, %27utm_source%27, %27utm_medium%27, %27utm_campaign%27, %27utm_content%27, %27utm_term%27];removeParameters(parms);})();

Test data

https://news.yahoo.com/12345?fbclid=xxx
https://my.website.com/tw/item/N2672356001001?utm_source=facebook&utm_medium=oth&utm_campaign=20221113&utm_content=20221113

Related