Skip to content

Instantly share code, notes, and snippets.

@gsajith
Created April 14, 2022 22:20
Show Gist options
  • Save gsajith/17fda22ed3c35bce95d1e0844f419e62 to your computer and use it in GitHub Desktop.
Save gsajith/17fda22ed3c35bce95d1e0844f419e62 to your computer and use it in GitHub Desktop.
Remove Twitter tracking tags - Tampermonkey Script
// ==UserScript==
// @name Twitter remove tracking tags
// @namespace twitter.com
// @version 0.1
// @description Remove Twitter tracking tags on desktop
// @author You
// @match *
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitter.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
document.addEventListener('copy', function(e){
const ORIGINAL_TEXT = e.target.innerText;
if (ORIGINAL_TEXT.includes('://twitter.com/') && ORIGINAL_TEXT.includes('?')) {
let newText = ORIGINAL_TEXT;
let tagStart = newText.indexOf('?');
newText = newText.substring(0, tagStart != -1 ? tagStart : newText.length);
navigator.clipboard.writeText(newText);
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment