Skip to content

Instantly share code, notes, and snippets.

@benjick
Last active September 24, 2023 18:13
Show Gist options
  • Save benjick/efe2b112732388ed4d8364ff4f142073 to your computer and use it in GitHub Desktop.
Save benjick/efe2b112732388ed4d8364ff4f142073 to your computer and use it in GitHub Desktop.
Trakt.tv - remove all items in Watchlist

Trakt watchlist remover

This script will remove everything* in your Trakt watchlist.
(* = tested with movies, shows, seasons, and episodes)

  1. Go to https://trakt.tv/users/me/watchlist (or any other list you want to empty out)
  2. Open the browser console. Easiest way is to right-click somewhere on the page and clicking "inspect" then selecting "console" in the menu.
  3. Paste the code attached in this gist and wait until the scripts says it is complete

The output should look something like this:

🔨 Removing ted lasso...
✅ Removed ted lasso!
🙌 All done! Please reload the window to see if it worked

⚠️ Do not run arbitrary code you don't understand in your console, a malicious actor could potentially steal your passwords

(async () => {
const token = document.querySelector('meta[name=csrf-token]').content;
const list_id = document.querySelector('#list-id').value;
for ({ dataset } of document.querySelectorAll('#sortable-grid .grid-item')) {
console.log(`🔨 Removing ${dataset.title}...`);
try {
const res = await fetch(`${dataset.url}/list/remove`, {
credentials: 'include',
body: Object.entries({
type: dataset.type,
trakt_id: dataset[`${dataset.type}Id`],
list_id,
})
.map(([key, value]) => `${key}=${value}`)
.join('&'),
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-CSRF-Token': token,
},
method: 'POST',
});
if (!res.ok) {
throw new Error(
`Could not remove from watchlist. Status ${res.status}`,
);
}
console.log(`✅ Removed ${dataset.title}!`);
} catch (error) {
console.log('☠️', error.message);
}
}
console.log(`🙌 All done! Please reload the window to see if it worked`);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment