Skip to content

Instantly share code, notes, and snippets.

@ViktorSchlaffer
Forked from mheler/clear-google-my-activity.js
Last active November 23, 2018 15:40
Show Gist options
  • Save ViktorSchlaffer/1b7a08b71b84474f7ac1220359862970 to your computer and use it in GitHub Desktop.
Save ViktorSchlaffer/1b7a08b71b84474f7ac1220359862970 to your computer and use it in GitHub Desktop.
A little script to clear all your history at https://myactivity.google.com/myactivity
/**
* A little script to clear all your history at https://myactivity.google.com/myactivity
*
* Load Developer Console (usually F12), paste this into the Console and hit Enter (or Run).
*
* Doesn't use any cool magic, just simulates clicking on all the delete buttons.
**/
var ClearGoogleMyAccount =
{
numTimesRun: 0,
numTimesToRun: 3,
init: function()
{
ClearGoogleMyAccount.loadjQuery();
// Give jQuery time to load, then get started
setTimeout(function(){
ClearGoogleMyAccount.queueClickDeleteButton();
}, 1000)
},
loadjQuery: function ()
{
// Load jQuerry, because it was quicker for me to script
var script = document.createElement("script");
script.src = "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js";
document.head.appendChild(script);
},
/**
* Clicks on all the Delete buttons which can be found - this causes a confirmation
* popup to appear
*/
clickDeleteButton: function () {
console.log("Clicking Delete Buttons");
jQuery('.swipe-div .fp-date-block-date-holder button').trigger('click');
jQuery('fp-date-block-date-holder button').trigger('click');
},
/**
* Click on all the confirmation popups which can be found - this does the actual deleting
*
**/
clickDeleteConfirmationButtons: function () {
console.log("Clicking Confirmation Buttons");
jQuery('[aria-label=Delete]').trigger('click');
},
/**
* So that we can keep deleting until everything is gone, we use a function which
* can call itself.
**/
queueClickDeleteButton: function ()
{
// Open up some dialog boxes
ClearGoogleMyAccount.clickDeleteButton();
console.log("Queueing clickDeleteConfirmationButtons in 1.5 seconds")
setTimeout(function(){
// Let the dialogs open, then click all the Confirmation buttons
ClearGoogleMyAccount.clickDeleteConfirmationButtons()
}, 2000)
// See how many items we have left to delete
var itemsRemaining = jQuery('.swipe-div .fp-date-block-date-holder button').length
console.log(itemsRemaining + " Items Remaining");
setTimeout(function(){
if (itemsRemaining > 0) {
// If we have some items left, start deleting them
ClearGoogleMyAccount.queueClickDeleteButton();
} else {
// To be sure we get everything, we run the script a few times. This accounts for Ajax loading/slow pages.
ClearGoogleMyAccount.numTimesRun++;
if (ClearGoogleMyAccount.numTimesRun < ClearGoogleMyAccount.numTimesToRun) {
console.log("Running Clear My Google Account count: " + ClearGoogleMyAccount.numTimesRun);
ClearGoogleMyAccount.queueClickDeleteButton();
} else {
console.log("Done!");
}
}
}, 5000)
}
}
ClearGoogleMyAccount.init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment