Skip to content

Instantly share code, notes, and snippets.

@intrnl

intrnl/clear_mal.js

Last active Feb 8, 2021
Embed
What would you like to do?
Clear MyAnimeList
let sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
let random = (min, max) => ~~(Math.random() * (max - min) + min);
let form_data = new FormData();
form_data.append('csrf_token', document.querySelector('meta[name=csrf_token]').content);
let elements = Array.from(document.querySelectorAll('.animetitle'));
console.log(`${elements.length} to delete`);
for (let i = 0; i < elements.length; i++) {
let el = elements[i];
let [, type, id] = (/\/(manga|anime)\/(\d+)/).exec(el.href);
let interval = random(2500, 7500);
console.log(`Deleting ${id} (${elements.length - i - 1} remaining), sleeping for ${interval}`);
await fetch(`https://myanimelist.net/ownlist/${type}/${id}/delete`, {
method: 'POST',
body: form_data,
});
await sleep(interval);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment