Skip to content

Instantly share code, notes, and snippets.

@rluvaton
Created July 1, 2020 11:23
Show Gist options
  • Save rluvaton/9e8e376967aeb4e3ae6434d66508e55f to your computer and use it in GitHub Desktop.
Save rluvaton/9e8e376967aeb4e3ae6434d66508e55f to your computer and use it in GitHub Desktop.
Remove all recording from terminalizer profile #helper #terminalizer #remove
function getAllRecordingsUrl() {
return Array.from(document.querySelectorAll('a[href^="/view/"]')).map(a => a.href)
}
function sendDeleteRecordingReq(id) {
return fetch(`https://terminalizer.com/delete/${id}`, {
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"accept-language": "en-US,en;q=0.9,he;q=0.8",
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "same-origin",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1"
},
"referrer": `https://terminalizer.com/edit/${id}`,
"referrerPolicy": "no-referrer-when-downgrade",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
});
}
async function removeAll() {
let success = 0;
let errors = 0;
const timer = async (ms) => new Promise(resolve => setTimeout(resolve, ms));
const recordingIds = getAllRecordingsUrl().map(url => url.replace('https://terminalizer.com/view/', ''));
const totalSize = recordingIds.length;
if(totalSize === 0) {
console.log('No recording found.');
return;
}
for (const id of recordingIds) {
try {
await sendDeleteRecordingReq(id);
success++;
} catch(e) {
console.error('Failed delete recording with id ' + id, e);
errors++;
}
console.table({errors, success, totalSize});
await timer(1500);
}
console.log(`Succeeded ${success} out of ${totalSize} with ${errors} errors`);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment