Last active
September 5, 2016 14:36
-
-
Save rEtSaMfF/874c6b64b0bfe6f3a4bf43be41279ddc to your computer and use it in GitHub Desktop.
Remove tumblr outgoing URL 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 fixTumblr | |
// @namespace https://gist.github.com/rEtSaMfF/874c6b64b0bfe6f3a4bf43be41279ddc | |
// @description Remove tumblr outgoing URL tracking. | |
// @include /^https?://.*\.tumblr\.com/?.*$/ | |
// @exclude /^https?://(secure\.)?(assets)\.tumblr\.com/.*$/ | |
// @version 2016-09-05 | |
// @run-at document-idle | |
// @grant none | |
// ==/UserScript== | |
// do not run on iframes | |
if (window.location.href.includes("iframe")) | |
return; | |
if (window.top != window.self) { | |
console.log("iframe: " + window.location); | |
//return; | |
} else { | |
console.log("NOT iframe: " + window.location); | |
} | |
function fixTumblr() { | |
var links = document.getElementsByTagName("a"); | |
var linksArray = Array.prototype.slice.call(links); | |
linksArray.forEach(function(link) { | |
var href = link.href; | |
if (! href.includes("umblr.com/redirect?z=")) | |
return; | |
var one = href.split("=")[1]; | |
var two = one.split("&"); | |
var decodedURL = decodeURIComponent(two[0]); | |
//console.log(link.href); | |
link.href = decodedURL; | |
//console.log(link.href); | |
}); | |
} | |
fixTumblr(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment