Archive all prismic documents
There are risks when using this script
⚠️ This snippet will archive all prismic documents
⚠️ Use it at your own risk
⚠️ I am not responsible for damages, penalties and/or possible bans
- Open your browser
- Go to your prismic dashboard
- open and paste the script bellow into your console
(async () => {
const MAX_QUERY_ITEMS = 1000;
const ANTI_DDOS_DELAY_MS = 500;
function getCookie(name) {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop().split(';').shift();
}
function wait(milliseconds) {
return new Promise((resolve) => setTimeout(resolve, milliseconds));
}
const docsRes = await fetch(`/app/documents/working?language=pt-br&page=1&limit=${MAX_QUERY_ITEMS}`, {
method: 'GET',
credentials: 'include',
});
if (!docsRes.ok) {
return;
}
const docs = await docsRes.json();
const publicDocs = docs.filter((doc) => doc.versionStatus === 'published');
console.log(`Moving ${publicDocs.length} documents to archive!!!`);
for (const doc of publicDocs) {
console.log('Moving to archive', doc.title);
const csrf = getCookie('X_XSRF'); // get rotating token
await fetch(`/app/documents/${doc.documentId}/versions/${doc.versionId}/archive?context=published&_=${csrf}`, {
method: 'POST',
credentials: 'include',
});
await wait(ANTI_DDOS_DELAY_MS);
}
console.log('Archive process finished');
})();