// ==UserScript== // @name Remove Prime Video Watch History with Floating Button // @namespace http://tampermonkey.net/ // @version 1.1 // @description Adds a floating button to remove all items from your Prime Video watch history with scrolling support, and removes the button when leaving the history page. // @author whmcfg // @match https://www.primevideo.com/* // @grant none // @license GNU GPLv3 // @downloadURL none // ==/UserScript== (function() { 'use strict'; function createButton() { // Check if the button already exists if (document.querySelector('#removeWatchHistoryButton')) return; // Create a floating button const button = document.createElement('button'); button.id = 'removeWatchHistoryButton'; button.innerText = 'Remove Watch History'; button.style.position = 'fixed'; button.style.bottom = '20px'; button.style.right = '20px'; button.style.padding = '10px 20px'; button.style.fontSize = '16px'; button.style.zIndex = '1000'; button.style.backgroundColor = '#ff9900'; button.style.color = '#fff'; button.style.border = 'none'; button.style.borderRadius = '5px'; button.style.cursor = 'pointer'; button.style.boxShadow = '0 2px 5px rgba(0,0,0,0.3)'; document.body.appendChild(button); button.addEventListener('click', function() { button.disabled = true; button.innerText = 'Removing...'; function removeAllWatchHistory() { let lastHeight = 0; function clickAndScroll() { const removeButtons = document.querySelectorAll('button.SPqQmU._3RF4FN._1D7HW3._2G6lpB.pU0yt1'); removeButtons.forEach((button, index) => { setTimeout(() => { button.click(); console.log(`Removed item ${index + 1} of ${removeButtons.length}`); }, index * 100); }); setTimeout(() => { window.scrollBy(0, document.body.scrollHeight); let newHeight = document.body.scrollHeight; if (newHeight > lastHeight) { lastHeight = newHeight; console.log("Scrolled down to load more videos..."); setTimeout(clickAndScroll, 2000); } else { console.log("All items removed from watch history."); button.innerText = 'Done!'; } }, removeButtons.length * 100 + 500); } clickAndScroll(); } removeAllWatchHistory(); }); } function removeButton() { const button = document.querySelector('#removeWatchHistoryButton'); if (button) { button.remove(); } } function checkForHistoryPage() { const urlIncludesHistory = window.location.href.includes('history'); if (urlIncludesHistory) { createButton(); } else { removeButton(); } } // Check initially if the current URL contains "history" checkForHistoryPage(); // Observe changes in the URL to detect navigation const observer = new MutationObserver(checkForHistoryPage); observer.observe(document.body, { childList: true, subtree: true }); })();