Last active
February 2, 2019 15:30
-
-
Save KonradLinkowski/8ec7d697c5c10784a8b412f6dfb5f5f5 to your computer and use it in GitHub Desktop.
Removes fbclid from facebook links.
This file contains 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
window.ddEventListener('click', event => { | |
const el = event.target | |
if (el.tagName.toLowerCase() === 'a') { | |
event.preventDefault() | |
const url = new URL(el.href) | |
url.searchParams.delete('fbclid') | |
window.open(url.href, el.target) | |
} | |
}, true) | |
// or | |
document.body.addEventListener('click', event => { | |
const el = event.target | |
if (el.tagName.toLowerCase() === 'a') { | |
event.preventDefault() | |
const url = new URL(new URL(el.href).searchParams.get('u')) | |
url.searchParams.delete('fbclid') | |
window.open(url.href, el.target) | |
} | |
}, true) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment