Skip to content

Instantly share code, notes, and snippets.

@therealzanfar
Last active December 3, 2022 15:55
Show Gist options
  • Save therealzanfar/de3eef4d985b5ff86e0d0dcaaff6f828 to your computer and use it in GitHub Desktop.
Save therealzanfar/de3eef4d985b5ff86e0d0dcaaff6f828 to your computer and use it in GitHub Desktop.
VERY DANGEROUS Greasemonkey script to delete your Trakt view history in bulk.
// ==UserScript==
// @name Trakt History Remover
// @namespace https://gist.github.com/therealzanfar
// @author Matthew W.
// @description Delete Trakt view history in bulk
// @version 1
// @match *://trakt.tv/users/*/history
// @match *://trakt.tv/users/*/history/*
// @run-at document-start
// @grant unsafeWindow
// ==/UserScript==
window.addEventListener("load", localMain);
var TRAKT_LOAD_DELAY = 2
var TRAKT_REMOVE_DELAY = 0.1;
var els = [];
var idx = 0;
function localMain() {
console.log("[TRAKT] Waiting for page to finish loading...");
setTimeout(removeElements, TRAKT_LOAD_DELAY * 1000);
}
function removeElements() {
els = document.getElementsByClassName("grid-item");
if (els.length > 1) {
console.log("[TRAKT] Found", els.length-1, "views to remove");
removeElement();
}
else {
console.log("[TRAKT] No views found");
}
}
function removeElement() {
if (idx >= els.length-1) {
console.log("[TRAKT] All elements removed, reloading page...");
setTimeout(reloadPage, TRAKT_LOAD_DELAY * 1000);
return;
}
var el = unsafeWindow.jQuery(els[idx]);
console.log("[TRAKT] Removing ", el.data("history-id"));
unsafeWindow.historyRemove(el, el.data("history-id"));
idx = idx + 1;
setTimeout(removeElement, TRAKT_REMOVE_DELAY * 1000);
}
function reloadPage() {
document.location.reload(true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment