Greasemonkey-Script-To-Clear-Google-History

Nifty Script of the Day

Harrison Horowitz’s nifty script (run via Greasemonkey in Firefoxor Tampermonkey in Chrome is a nifty way to avoid a LOT of repetitive clicking, if you are interested in deleting your Google Search History.

Wait, Didn’t I Disable That Stuff?

Google isn’t Facebook… but I do think they’ve re-enabled some things which I explicitly disabled before. It is definitely worth checking on your history, if you think you turned it off, but aren’t sure. I thought my history was definitely disabled, but apparently something reenabled it a few months ago, along with tailored advertising (which I am certain I disabled immediately upon it’s release years back).

See what Google is storing about you with their Dashboard

Script Issues

Using the script: after installing greasemonkey select “New User Script” from the drop down, https://history.google.com/history/* to includes, copy the script below, and select “Use script from clipboard.” Viola. It should run. If it doesn’t you may need to CMD+Shift+R.

  
/ ==UserScript==
// @name       Automatically delete all Google Web History (page after page...)
// @version    1.2.3.4.5.6.4
// @description  This will delete all of your web history Google saves about you, one page at a time. Just go to https://history.google.com/history and login.
// @match      https://history.google.*/history*
// @match      http://history.google.*/history*
// @grant     GM_deleteValue
// @grant     GM_getValue
// @grant     GM_setValue
// @grant     GM_info
// @author    Harrison Horowitz
// @license    MIT
// ==/UserScript==

var deleteButton;

function findButtonAndClick() {
    console.log("clicking delete");
    if (typeof document.edit != "undefined") {
        document.edit.btnD.click();
    } else {
        if (typeof deleteButton != "undefined") {
            deleteButton.click();
        } else {
            //window.location.reload();// = "https://history.google.com/history/delete?hl=en&btnD";
            var nodeList = document.getElementsByName("btnD");
            nodeList[0].click();
        }
    }
}

function doItYo(){
    try {
        console.log("clicking selector_top");
        document.getElementById("selector_top").click();
        setTimeout(findButtonAndClick, 1100);
    } catch (err) {console.log(err);}
}

// a function that loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
    var script = document.createElement("script");
    script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"); // //ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
    script.addEventListener('load', function() {
        var script = document.createElement("script");
        script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
        document.body.appendChild(script);
    }, false);
    document.body.appendChild(script);
}

// the guts of this userscript
function mainKillHistory() {
    var deleteButton = jQ("input.kd-button");
    //debugger;
    jQ(document).on("ready", clickThem);
    jQ(".selector_top").click();
    jQ("input.kd-button").click();
}

document.addEventListener('DOMContentLoaded', function() {
    setTimeout(doItYo, 5000);
});

addJQuery(mainKillHistory);



try {
    function timedRefresh(timeoutPeriod) {
        console.log("Refreshing...");
        setTimeout(location.reload(true), timeoutPeriod);
        //console.log(getStackTrace());
        console.log("Finsished....");
    }   
} catch (err) {
    console.log(err);
  

Issues

Chrome will randomly serve 502s and log you out while this script is running. You may be getting flagged for hitting the site too many times… which is stupid, because they’re the ones force you to do that… or it may just be that you’re causing a lot of errors. This script does use a bunch of deprecated stuff //@ and getAttributeNode() as well as logging some reference errors… but… that doesn’t really seem to affect performance.

comments powered by Disqus