Skip to content

Instantly share code, notes, and snippets.

@mysticatea
Created September 20, 2017 02:09
Show Gist options
  • Save mysticatea/b07c457eee71766d2df09b05159e5fee to your computer and use it in GitHub Desktop.
Save mysticatea/b07c457eee71766d2df09b05159e5fee to your computer and use it in GitHub Desktop.
Tampermonkey
// ==UserScript==
// @name Remove utm_
// @namespace http://mysticatea.jp/
// @version 1.0.0
// @description Remove utm_* from URL parameters.
// @author Toru Nagashima
// @match *://*/*?*utm_*
// @grant none
// ==/UserScript==
const url = new URL(location.href)
let removed = false
for (const key of url.searchParams.keys()) {
if (key.startsWith("utm_")) {
url.searchParams.delete(key)
removed = true
}
}
if (removed) {
history.replaceState(null, null, url)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment