您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
截圖通知欄變空白的畫面
// ==UserScript== // @name YouTube通知回報工具 // @namespace Violentmonkey Scripts // @match https://www.youtube.com/ // @grant none // @version 1.1 // @author Artin Lin // @license MIT // @description 截圖通知欄變空白的畫面 // ==/UserScript== function waitForButton(callback, maxAttempts = 10) { let attempts = 0; function checkButton() { const targetButton = document.querySelector('button#button[aria-label="通知"]'); if (targetButton) { console.log('找到通知按鈕'); callback(targetButton); } else { attempts++; if (attempts < maxAttempts) { console.log(`尋找按鈕中... 嘗試 ${attempts}/${maxAttempts}`); setTimeout(checkButton, 1000); // 每秒檢查一次 } else { console.error('無法找到通知按鈕,已超過最大嘗試次數'); } } } checkButton(); } window.addEventListener('load', function() { // 等待頁面完全加載 waitForButton(function(targetButton) { let hasClicked = false; window.addEventListener('blur', function() { if (window.location.hostname.includes('youtube.com') && !hasClicked) { targetButton.click(); hasClicked = true; console.log('頁面失去焦點,已點擊通知按鈕'); } }); console.log('腳本已啟動,當YouTube頁面首次失去焦點時將觸發通知按鈕'); }); });