Last active
November 20, 2015 12:55
-
-
Save iambibhas/a6535dc3891f21c5cbbd to your computer and use it in GitHub Desktop.
UserScript to avoid Facebook's URL director
This file contains hidden or 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 Facebook URL Redirector Bypass | |
// @namespace in.bibhas | |
// @include https://*.facebook.com/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
si = window.setInterval(clearanchors, 2000); | |
function clearanchors(){ | |
anchors = document.getElementsByTagName('a'); | |
for(i=0;i<anchors.length;i++){ | |
var poisoned_url = anchors[i].getAttribute('href'); | |
if(poisoned_url && poisoned_url.match(/(http|https):\/\/(l|www).facebook.com\/l\.php\?u\=(.*)/g)){ | |
poisoned_url = poisoned_url.replace(/(http|https):\/\/(l|www).facebook.com\/l\.php\?u\=/g, ''); | |
poisoned_url = poisoned_url.replace(/\&h\=.*/g, ''); | |
anchors[i].setAttribute('class', ''); | |
anchors[i].setAttribute('onclick', ''); | |
anchors[i].setAttribute('target', '_blank'); | |
anchors[i].setAttribute('href', decodeURIComponent(poisoned_url)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment