Skip to content

Instantly share code, notes, and snippets.

@mysteriouss
Created June 13, 2022 19:00
Show Gist options
  • Save mysteriouss/ec6082759e6dec2e5840ae69f5a8930a to your computer and use it in GitHub Desktop.
Save mysteriouss/ec6082759e6dec2e5840ae69f5a8930a to your computer and use it in GitHub Desktop.
Google Search Cleaner
// ==UserScript==
// @name Google
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.google.com/search*
// @icon https://www.google.com/s2/favicons?domain=google.com
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
setInterval(function() {
$('a').removeAttr("onclick");
$('a').unbind("click");
$('a').bind("click",function(event){
event.preventDefault();
event.stopPropagation();
console.log(event.currentTarget.href);
let targetUrl = decodeURIComponent(decodeURI(event.currentTarget.href)
.replace('?', '')
.split('&')
.map(param => param.split('='))
.reduce((values, [ key, value ]) => {
values[ key ] = value
return values
}, {}).url);
console.log('targetUrl:' + targetUrl);
if(targetUrl && targetUrl != 'undefined' ){
window.open(targetUrl);
}
return false;
});
},100);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment