-
-
Save leeramsay/0a8dcd00d32e38a4a4e9a6494aac1fa0 to your computer and use it in GitHub Desktop.
Greasemonkey user script: Remove Facebook's external link tracking
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
// ==UserScript== | |
// @name Remove Facebook's external link tracking | |
// @description Removes redirection from external FB links | |
// @namespace https://gist.github.com/k-barton | |
// @include https://*.facebook.com* | |
// @include http://*.facebook.com* | |
// @version 0.1.0 | |
// @grant none | |
// ==/UserScript== | |
(function () { | |
var redirectionUrl = 'https://l.facebook.com/l.php'; | |
var fix_link = function (el) { | |
var isFixed = false; | |
var onclick = el.getAttribute('onclick'); | |
if (onclick !== null && onclick.indexOf('LinkshimAsyncLink') != - 1) { | |
el.removeAttribute('onclick'); | |
el.removeAttribute('onmouseover'); | |
isFixed = true; | |
} | |
if (el.href.indexOf(redirectionUrl) > - 1) { | |
var href = el.href; | |
var s = href.substring(href.indexOf('?') + 1); | |
s = s.split('&'); | |
for (var i in s) { | |
if (s[i].indexOf('u=') === 0) { | |
s = s[i]; | |
el.href = decodeURIComponent(s.substring(s.indexOf('=') + 1)); | |
isFixed = true; | |
break; | |
} | |
} | |
} | |
if (isFixed && el.textContent !== '') el.style.backgroundColor = '#FFEE22'; | |
}; | |
document.addEventListener('DOMContentLoaded', function (event) { | |
document.onmouseover = function (event) { | |
if (event.target.tagName == 'A') | |
fix_link(event.target); | |
}; | |
}, false); | |
}) (); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment