(async () => {
const t = document.querySelector('meta[name="csrf-token"]').content;
const KEEP = new Set([481108, 483015, 483019]);
const d = await fetch('/issues/64173.json?include=journals', { credentials: 'include' }).then(r => r.json());
const ids = d.issue.journals
.filter(j => ((j.notes || '') + '').indexOf('Autogenerated') > -1)
.map(j => j.id)
.filter(id => !KEEP.has(id));
console.log(ids.length + ' dupes to blank');
let ok = 0, fail = 0;
for (const id of ids) {
const r = await fetch('/journals/' + id + '?journal%5Bnotes%5D=', {
method: 'PUT',
headers: { 'X-CSRF-Token': t, 'X-Requested-With': 'XMLHttpRequest' },
credentials: 'include'
});
if (r.ok || r.status === 302) ok++;
else { fail++; console.log('fail', id, r.status); }
if (ok % 50 === 0) console.log('progress', ok + '/' + ids.length);
await new Promise(s => setTimeout(s, 300));
}
console.log('DONE ok=' + ok + ' fail=' + fail);
})()
≡ hart