Skip to content

Instantly share code, notes, and snippets.

@KonradLinkowski
Last active February 2, 2019 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KonradLinkowski/8ec7d697c5c10784a8b412f6dfb5f5f5 to your computer and use it in GitHub Desktop.
Save KonradLinkowski/8ec7d697c5c10784a8b412f6dfb5f5f5 to your computer and use it in GitHub Desktop.
Removes fbclid from facebook links.
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