// ==UserScript== // @name Primevideo Visual Cleanup and Volume Control // @namespace http://tampermonkey.net/ // @version 1.5 // @license MIT // @description Removes X-ray and black shadow from streaming, also adds mouse wheel volume control. // @author jkillas // @match *.primevideo.com/* // @grant GM_addStyle // @downloadURL https://update.greasyfork.icu/scripts/527500/Primevideo%20Visual%20Cleanup%20and%20Volume%20Control.user.js // @updateURL https://update.greasyfork.icu/scripts/527500/Primevideo%20Visual%20Cleanup%20and%20Volume%20Control.meta.js // ==/UserScript== (function() { 'use strict'; // Add custom CSS GM_addStyle(` .atvwebplayersdk-player-container .hideUntilCssLoaded .xrayQuickView { display: none !important; } .fkpovp9 { background: none !important; } #pip-button { display: none !important; } `); const DEBUG_MODE = false; function debugLog(message) { if (DEBUG_MODE) { console.log(message); } } function createVolumeDisplay() { let volumeDisplay = document.getElementById('volume-display'); if (!volumeDisplay) { volumeDisplay = document.createElement('div'); volumeDisplay.id = 'volume-display'; Object.assign(volumeDisplay.style, { position: 'fixed', top: '10px', left: '10px', fontSize: '18px', background: 'rgba(0, 0, 0, 0.8)', color: '#ffffff', padding: '8px 12px', borderRadius: '8px', zIndex: 10000, display: 'none', fontWeight: 'bold', textShadow: '1px 1px 2px rgba(0,0,0,0.5)', boxShadow: '0 4px 6px rgba(0,0,0,0.1)', transition: 'opacity 0.3s', border: '1px solid rgba(255,255,255,0.2)' }); document.body.appendChild(volumeDisplay); debugLog('Volume display initialized'); } return volumeDisplay; } // Create mute icon SVG const muteIconSVG = ` `; function updateVolumeDisplay(volumeDisplay, volume) { volumeDisplay.style.display = 'block'; volumeDisplay.style.opacity = '1'; // Check if volume is muted if (volume <= 0.01) { volumeDisplay.innerHTML = muteIconSVG + 'Muted'; volumeDisplay.style.color = '#ffffff'; // Don't set any timeout for hiding when muted return; } volumeDisplay.textContent = 'Volume: ' + Math.round(volume * 100) + '%'; debugLog('Volume display updated'); // Color scheme for non-muted states if (volume <= 0.25) { // Low volume: Soft blue volumeDisplay.style.color = '#4A90E2'; } else if (volume <= 0.5) { // Medium-low volume: Gentle green volumeDisplay.style.color = '#2ECC71'; } else if (volume <= 0.75) { // Medium-high volume: Warm orange volumeDisplay.style.color = '#F39C12'; } else { // High volume: Vibrant red volumeDisplay.style.color = '#E74C3C'; } } function handleWheelEvent(volumeDisplay) { let volumeTimeoutId = 0; return function(e) { let video = document.querySelector('#dv-web-player video'); debugLog('Video player found: ' + video); if (video) { let newVolume = video.volume + (e.deltaY < 0 ? 0.1 : -0.1); debugLog('New volume calculated: ' + newVolume); video.volume = Math.max(0, Math.min(1, newVolume)); updateVolumeDisplay(volumeDisplay, video.volume); // Clear any existing timeout if (volumeTimeoutId) { clearTimeout(volumeTimeoutId); } // Only set timeout to hide display if volume is above muted threshold if (video.volume > 0.01) { volumeTimeoutId = setTimeout(function() { debugLog('Fading out volume display'); volumeDisplay.style.display = 'none'; volumeDisplay.style.opacity = '0'; }, 3000); } e.preventDefault(); } }; } const volumeDisplay = createVolumeDisplay(); const observer = new MutationObserver(function(mutations, observer) { for(let mutation of mutations) { debugLog(mutation); } const video = document.querySelector('#dv-web-player'); if (video) { debugLog("'#dv-web-player' has been loaded in the DOM."); video.addEventListener('wheel', handleWheelEvent(volumeDisplay), {passive: false}); observer.disconnect(); debugLog('Disconnected the observer since the video element has been found.'); } }); debugLog('Starting to observe the whole document for addition of the video element.'); observer.observe(document, {childList: true, subtree: true}); })();