Created
July 22, 2019 16:19
-
-
Save Nemo64/5fd0fa5359c0ccbc04af883eae8ffd67 to your computer and use it in GitHub Desktop.
This is a userscript for tampermonkey to automatically remove a bunch of urls from google.
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 Bulk removal google hack | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Bulk remove a search result from google | |
// @author Marco Pfeiffer | |
// @match https://www.google.com/webmasters/tools/removals* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// search for the site you want to remove using eg. 'site:example.com' | |
// configure the search result to render 100 urls per page | |
// then run this script in your console: | |
// localStorage['removals'] = JSON.stringify([].slice.call(document.querySelectorAll('.r > a[href]')).map(a => a.href).filter(href => href.indexOf("http://example.com") === 0)); | |
// (adjust the filter for your site; check if all urls are correct) | |
// then load https://www.google.com/webmasters/tools/removals?pli=1 | |
// the local storage queue will be processed. | |
let removals = JSON.parse(localStorage.removals); | |
if (removals.length > 0) { | |
var pollForTextBox = function () { | |
var textBox = document.querySelector('input'); | |
if (!textBox) { | |
setTimeout(pollForTextBox, 200); | |
} else { | |
textBox.value = removals[0]; | |
document.querySelector('#gwt-uid-28').click(); | |
pollForRemoval(); | |
} | |
}; | |
var pollForRemoval = function () { | |
var removal = document.querySelector('#gwt-uid-88'); | |
if (!removal) { | |
setTimeout(pollForRemoval, 200); | |
} else { | |
removal.click(); | |
pollForOk(); | |
} | |
}; | |
var pollForOk = function () { | |
var ok = document.querySelector('#gwt-uid-96'); | |
if (!ok) { | |
setTimeout(pollForOk, 200); | |
} else { | |
ok.click(); | |
// remove that entry from the removals list | |
localStorage.removals = JSON.stringify(removals.slice(1)); | |
} | |
}; | |
pollForTextBox(); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment