Skip to content

Instantly share code, notes, and snippets.

@JenieX
Created September 17, 2023 10:48
Show Gist options
  • Save JenieX/5014738fd3be45d7ce4ec3880c47fb50 to your computer and use it in GitHub Desktop.
Save JenieX/5014738fd3be45d7ce4ec3880c47fb50 to your computer and use it in GitHub Desktop.
Letterboxd - clear films in current page from watched list
/** @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