Created
December 15, 2018 21:37
-
-
Save jwh315/808f5dc26ef823b551401e1dc9fa9dee to your computer and use it in GitHub Desktop.
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
var cleanUp = { | |
domains: [], | |
getDomains: async function() { | |
let results = null; | |
let page = 0 | |
do { | |
const response = await fetch(`https://prerender.io/api/cached-pages?page=${page}&pageSize=1000`); | |
const json = await response.json(); | |
results = json; | |
json.map(item => cleanUp.domains.push(item.url)); | |
console.log("Found domains " + json.length); | |
page++; | |
} while (results.length); | |
}, | |
deleteDomain: async function(domain, cookie) { | |
console.log(`deleting domain ${domain}`); | |
let response = await fetch("https://prerender.io/api/remove-cached-url?url=" + encodeURIComponent(domain), { | |
method: "DELETE", | |
headers: { | |
"x-xsrf-token": cookie | |
} | |
}); | |
console.log(`doamin deleted ${domain}`); | |
cleanUp.deleteDomain(cleanUp.domains.pop(), cookie); | |
}, | |
getCookie: function() { | |
var name = 'XSRF-TOKEN'; | |
var value = "; " + document.cookie; | |
var parts = value.split("; " + name + "="); | |
if (parts.length == 2) return parts.pop().split(";").shift(); | |
}, | |
init: async function() { | |
await cleanUp.getDomains(); | |
cleanUp.deleteDomain(cleanUp.domains.pop(), cleanUp.getCookie()); | |
console.log("done"); | |
} | |
}; | |
cleanUp.init(); |
This is so fu**ing amazing! They should have implemented that in their UI though....
Actually, they should implement a batch delete official api...
I found another quick way for a few thousands of links
I navigate to https://prerender.io/?q=&pageSize=1000 and then I can use their button to concurrently delete all the 1000 within a few seconds
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this!