Created
September 17, 2023 10:48
-
-
Save JenieX/5014738fd3be45d7ce4ec3880c47fb50 to your computer and use it in GitHub Desktop.
Letterboxd - clear films in current page from watched list
This file contains 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
/** @param {number} milliSeconds */ | |
async function sleep(milliSeconds) { | |
return new Promise((resolve) => { | |
setTimeout(resolve, milliSeconds); | |
}); | |
} | |
const elements = /** @type {HTMLSpanElement[]} */ ([ | |
...document.querySelectorAll('span[data-action$="/mark-as-not-watched/"]'), | |
]); | |
const tabURL = window.location.href; | |
const needle = /letterboxd\.com\/[^/]+\/films\/rated\/none\//; | |
(async () => { | |
console.clear(); | |
if (!needle.test(tabURL)) { | |
throw new Error( | |
'Only works for pages like "https://letterboxd.com/your-username/films/rated/none/".', | |
); | |
} | |
for (const [index, element] of elements.entries()) { | |
console.log(`[${index + 1}/${elements.length}]: ${element.dataset.action}`); | |
element.click(); | |
await sleep(1000); | |
} | |
})().catch((exception) => console.error(exception)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment