您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Removes the annoying gradients visible when pausing a video.
当前为
// ==UserScript== // @name Youtube Hide Paused Gradient by Sapioit // @namespace Sapioit // @copyright Sapioit, 2020 - Present // @author sapioitgmail.com // @license GPL-2.0-only; http://www.gnu.org/licenses/gpl-2.0.txt // @icon https://youtube.com/favicon.ico // @match https://www.youtube.com/* // @match http*://*.youtube.com/* // @match http*://youtube.com/* // @match https://youtu.be/* // @match http*://*.youtu.be/* // @description Removes the annoying gradients visible when pausing a video. // @version 1.5.1.1 // @grant GM_addStyle // @grant GM_registerMenuCommand // @grant GM_setValue // @grant GM_getValue // ==/UserScript== function title_changed (count = 3) { console.log("Sapioit: Checking title change."); // Check if the value of the title (the first "yt-formatted-string.style-scope.ytd-watch-metadata" element) has changed const firstWatchMetadataElement = ( document.querySelectorAll('yt-formatted-string.style-scope.ytd-watch-metadata') )[0]; if (firstWatchMetadataElement) { // Get the current value of the title const currentWatchMetadataValue = firstWatchMetadataElement.textContent.trim(); // Get the consecutive unchanged count from localStorage, or set it to 0 if it's not available let consecutiveUnchangedCount = parseInt(localStorage.getItem('consecutiveUnchangedCount')) || 0; // Check if the current value is the same as the previous one stored in localStorage if (localStorage.getItem('currentWatchMetadataValue') === currentWatchMetadataValue) { // Increment the consecutiveUnchangedCount if the value is the same consecutiveUnchangedCount++; // Update the stored value and consecutiveUnchangedCount in localStorage localStorage.setItem('currentWatchMetadataValue', currentWatchMetadataValue); localStorage.setItem('consecutiveUnchangedCount', consecutiveUnchangedCount.toString()); // Stop the function if the title value hasn't changed for the last three checks (consecutiveUnchangedCount is less than 4) if (consecutiveUnchangedCount < (count+1) ) { console.log("Sapioit: First 'yt-formatted-string.style-scope.ytd-watch-metadata' element has not changed for the last three checks. Stopping check."); return false; // Return that the title has not changed. } else { // Reset the consecutiveUnchangedCount if the value has changed consecutiveUnchangedCount = 0; // Update the stored value and consecutiveUnchangedCount in localStorage localStorage.setItem('currentWatchMetadataValue', currentWatchMetadataValue); localStorage.setItem('consecutiveUnchangedCount', consecutiveUnchangedCount.toString()); return true; // Return that the title has changed. } } else { // Reset the consecutiveUnchangedCount if the value has changed consecutiveUnchangedCount = 0; // Update the stored value and consecutiveUnchangedCount in localStorage localStorage.setItem('currentWatchMetadataValue', currentWatchMetadataValue); localStorage.setItem('consecutiveUnchangedCount', consecutiveUnchangedCount.toString()); return true; // Return that the title has changed. } } return true; // Return that the title has changed. // Usage example: if ( title_changed() ){ return; } if ( title_changed(8) ){ return; } } function swapButtonsSaveShare(){ console.log('Starting the swap.'); function swapButtons() { const saveButton = document.querySelector('ytd-button-renderer[button-renderer][button-next] button[aria-label="Save to playlist"]'); const shareButton = document.querySelector('ytd-button-renderer[button-renderer][button-next] button[aria-label="Share"]'); if (saveButton && shareButton) { const saveButtonParent = saveButton.parentElement; const shareButtonParent = shareButton.parentElement; saveButtonParent.insertBefore(shareButton, saveButtonParent.firstChild); shareButtonParent.insertBefore(saveButton, shareButtonParent.firstChild); saveButton.style.width = 'auto'; // To remove the old "Save" and "Share" buttons, uncomment the lines below: // saveButtonParent.removeChild(saveButton); // shareButtonParent.removeChild(shareButton); } } function areButtonsNotSwapped() { console.log('Sapioit :: Check if buttons are swapped.'); console.log("Sapioit ::: Checking if 'Save' button is inside the top-level-buttons-computed element."); const isSaveButtonInside = !!document.querySelector('div#top-level-buttons-computed.top-level-buttons.style-scope.ytd-menu-renderer button[aria-label="Save to playlist"]'); if (isSaveButtonInside) { console.log("Sapioit :: 'Save' button is inside the top-level-buttons-computed element."); return false; } else { console.log("Sapioit :: 'Save' button is NOT inside the top-level-buttons-computed element."); return true; } return false; } if ( areButtonsNotSwapped() ) { console.log("Sapioit :: before swapItems."); // Run the swapButtons function initially swapButtons(); console.log("Sapioit :: after swapItems."); } else { console.log("Sapioit :: avoided swapItems."); } } function add_hover_tooltips() { /*var video_titles = document.getElementsByTagName("h3").getElementsByClassName("ytd-compact-video-renderer").getElementsByTagName("span");*/ /*var video_titles = document.querySelector("span.ytd-compact-video-renderer");*/ //var video_titles = document.getElementsByTagName("span").getElementsByClassName("ytd-compact-video-renderer"); /*var video_titles = document.querySelectorAll("span.ytd-compact-video-renderer");*/ var video_titles = document.querySelectorAll("span.ytd-compact-video-renderer, #video-title"); for(var i=0; i<video_titles.length; i++){ console.log(video_titles[i]); var current_title = video_titles[i].getAttribute("title"); video_titles[i].setAttribute("alt", current_title); video_titles[i].setAttribute("data-title", current_title); video_titles[i].setAttribute("data-tooltip", current_title); } /* video_titles = document.querySelectorAll("#video-title"); for(i=0; i<video_titles.length; i++){ console.log(video_titles[i]); current_title = video_titles[i].getAttribute("title"); video_titles[i].setAttribute("alt", current_title); video_titles[i].setAttribute("data-title", current_title); video_titles[i].setAttribute("data-tooltip", current_title); } */ } window.onloadstart = function(){setTimeout(function () { add_hover_tooltips(); }, 0.001*1000)}; //loads after 0.001 seconds window.addEventListener('keydown', function(e) { let play_button = document.querySelector('button.ytp-play-button'); let valid_target = e.target === document.body || e.target === document.querySelector('#player-api'); let pressed_space = e.keyCode === 32 || e.keyCode === 'Space'; // Space if (play_button && valid_target && pressed_space) { console.log("Sapioit: Pressed pause or resume."); e.preventDefault(); playButton.click(); } }); if (typeof document.getElementsByClassName("ytp-gradient-top")[0] != "undefined") { document.getElementsByClassName("ytp-gradient-top")[0].style.display = 'none'; } if (typeof document.getElementsByClassName("ytp-gradient-top")[0] != "undefined") { document.getElementsByClassName("ytp-gradient-top")[0].style.opacity = '0'; } if (typeof document.getElementsByClassName("ytp-gradient-bottom")[0] != "undefined") { document.getElementsByClassName("ytp-gradient-bottom")[0].style.display = 'none'; } if (typeof document.getElementsByClassName("ytp-gradient-bottom")[0] != "undefined") { document.getElementsByClassName("ytp-gradient-bottom")[0].style.opacity = '0'; } /* document.getElementsByClassName("ytp-gradient-top")[0].style.display = 'none'; document.getElementsByClassName("ytp-gradient-top")[0].style.opacity = '0'; document.getElementsByClassName("ytp-gradient-bottom")[0].style.display = 'none'; document.getElementsByClassName("ytp-gradient-bottom")[0].style.opacity = '0'; */ GM_addStyle('.ytp-caption-window-container { top: 2% !important; }'); GM_addStyle('.ytp-gradient-top { display: none !important; opacity: 0 !important; }'); GM_addStyle('.ytp-gradient-top { width: none !important; opacity: 0 !important; }'); GM_addStyle('button div.ytp-autonav-toggle-button-container { display: none !important;}'); GM_addStyle('[data-tooltip-target-id="ytp-autonav-toggle-button"] { display: none !important;}'); //GM_addStyle('.ytp-button[data-tooltip-target-id="ytp-autonav-toggle-button"] { display: none !important;}'); GM_addStyle('--ytd-engagement-panel-section-list-rendere { display: none !important;}'); GM_addStyle('.ytp-time-display > span { padding: 3px; background: rgba(0, 0, 0, 0.5); }'); //GM_addStyle('.ytd-thumbnail-overlay-time-status-renderen { transition-duration: 0s; }'); window.onload = function(){setTimeout(function () { GM_addStyle('button div.ytp-autonav-toggle-button-container { display: none !important;}'); GM_addStyle('[data-tooltip-target-id="ytp-autonav-toggle-button"] { display: none !important;}'); GM_addStyle('--ytd-engagement-panel-section-list-rendere { display: none !important;}'); GM_addStyle('#video-title.ytd-compact-video-renderer { overflow: none !important;}'); GM_addStyle('ytd-button-renderer > yt-button-shape > button[aria-label="Thanks"] { display: none !important; }'); //GM_addStyle('ytd-button-renderer > yt-button-shape > button[aria-label="Save to playlist"] { display: inline-block !important; }'); add_hover_tooltips(); swapButtonsSaveShare(); setTimeout(function () { swapButtonsSaveShare(); }, 5*1000) //loads after 5 seconds //GM_addStyle('.ytd-thumbnail-overlay-time-status-renderen { transition-duration: 0s; }'); }, 5*1000)}; //loads after 5 seconds function repeaterFunction(){ if ( title_changed(12) ){ return; } GM_addStyle('button div.ytp-autonav-toggle-button-container { display: none !important;}'); GM_addStyle('[data-tooltip-target-id="ytp-autonav-toggle-button"] { display: none !important;}'); GM_addStyle('--ytd-engagement-panel-section-list-rendere { display: none !important;}'); swapButtonsSaveShare(); setTimeout(repeaterFunction, 30*1000); //loads every 30 seconds } repeaterFunction(); GM_addStyle("span[data-tooltip]:before { z-index:301; content: attr(data-tooltip); position: absolute; opacity: 0; padding: 10px; background: black; color: white;} span[data-tooltip]:hover:before { opacity: 1;} "); GM_addStyle(".yt-simple-endpoint[title]:before { z-index:301; content: attr(title); position: absolute; opacity: 0; padding: 10px; background: black; color: white;} .yt-simple-endpoint[title]:hover:before { opacity: 1 !important;} "); // <ytd-engagement-panel-section-list-renderer class="style-scope ytd-watch-flexy" visibility="ENGAGEMENT_PANEL_VISIBILITY_EXPANDED">GM_addStyle(a);
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址