Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
UserScript to avoid Facebook's URL director
// ==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
You can’t perform that action at this time.