Last active
December 13, 2017 20:01
-
-
Save mwurzberger/ab83f6f005afce59bb41 to your computer and use it in GitHub Desktop.
Userscript - Google Redirect Remover
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 Google Redirect Remover | |
// @namespace https://gist.github.com/mwurzberger/ab83f6f005afce59bb41 | |
// @description Stop google links from using their tracking redirect | |
// @version 1.0.0 | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js | |
// @include http://*.google.com/* | |
// @include https://*.google.com/* | |
// ==/UserScript== | |
if( !googleRedirectRemover ) { var googleRedirectRemover = {}; } | |
googleRedirectRemover = { | |
loggingEnabled: true, | |
oldConsoleLog: null, | |
initialize: function() | |
{ | |
this.disableLogger(); | |
console.log('googleRedirectRemover.initialize'); | |
$('a').on('mousedown', $.proxy(this.handleLinkMousedown, this)); | |
$('a').on('click', $.proxy(this.handleLinkClick, this)); | |
}, | |
enableLogger: function() | |
{ | |
if( this.oldConsoleLog == null ) { return; } | |
window['console']['log'] = this.oldConsoleLog; | |
}, | |
disableLogger: function() | |
{ | |
this.oldConsoleLog = console.log; | |
window['console']['log'] = function() {}; | |
}, | |
handleLinkMousedown: function( event ) | |
{ | |
console.log('googleRedirectRemover.handleLinkMousedown'); | |
this.resetElementHref($(event.currentTarget)); | |
}, | |
handleLinkClick: function( event ) | |
{ | |
console.log('googleRedirectRemover.handleLinkClick'); | |
this.resetElementHref($(event.currentTarget)); | |
}, | |
resetElementHref: function( $element ) | |
{ | |
console.log('googleRedirectRemover.resetElementHref'); | |
var href = $element.data('href'); | |
if( href == undefined ) | |
{ | |
return; | |
} else { | |
console.log(href); | |
$element.attr('href', href); | |
} | |
} | |
} | |
$(document).ready(function() { | |
googleRedirectRemover.initialize(); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment