Skip to content

Instantly share code, notes, and snippets.

@iambibhas
Last active November 20, 2015 12:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iambibhas/a6535dc3891f21c5cbbd to your computer and use it in GitHub Desktop.
Save iambibhas/a6535dc3891f21c5cbbd to your computer and use it in GitHub Desktop.
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