您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
auto continue when it asks to press 'yes' to keep playing
当前为
// ==UserScript== // @name music.youtube.com auto continue playback // @namespace q1k // @version 1.5 // @description auto continue when it asks to press 'yes' to keep playing // @author q1k // @match *://music.youtube.com/* // @grant none // @run-at document-idle // ==/UserScript== var check_playback_interval = 1000; //enter interval time in ms (1000ms = 1second) //beware of low values-- browser/system slowdowns may occur var play_text = "play"; // if your language is not english change this to match var pause_text = "pause"; // if your language is not english change this to match var autostart = false; // should it be enabled by default?,.. //if you set this to true make sure to allow auto-playing of sounds,,, see description below for more info var playbackbutton; var autocontinue; var checkplaybackID; var userPauseDetected=false; var skipcheck=false; var clickedButton=false; var checkplaybackstatus = document.createElement('div'); checkplaybackstatus.setAttribute("id","checkplaybackstatus"); checkplaybackstatus.setAttribute("style","position:fixed;bottom:85px;left:12px;/*top:45px;left: 50%;transform:translateX(-50%);*/padding:15px;pointer-events:none;font-size:2em;background:rgba(180,180,180,1);z-index:999999999;"); checkplaybackstatus.setAttribute("class","myfadeoutclass"); checkplaybackstatus.innerText=""; var checkboxdiv = document.createElement("div"); checkboxdiv.setAttribute("class","onoffswitch"); checkboxdiv.setAttribute("title","Playback checker (hotkey: X)"); var checkboxinput = document.createElement("input"); checkboxinput.setAttribute("type","checkbox"); checkboxinput.setAttribute("name","onoffswitch"); checkboxinput.setAttribute("class","onoffswitch-checkbox"); checkboxinput.setAttribute("id","myonoffswitch"); if (autostart){ checkboxinput.checked=true; autocontinue=true; } else { checkboxinput.checked=false; autocontinue=false; } var checkboxinputlabel = document.createElement("label"); checkboxinputlabel.setAttribute("class","onoffswitch-label"); checkboxinputlabel.setAttribute("for","myonoffswitch"); checkboxinputlabel.innerHTML="<span class='onoffswitch-inner'></span><span class='onoffswitch-switch'></span>"; checkboxdiv.appendChild(checkboxinput); checkboxdiv.appendChild(checkboxinputlabel); document.body.appendChild(checkplaybackstatus); var myCSS = document.createElement("style"); myCSS.innerHTML=".myfadeoutclass{transition:opacity 1s ease-in;transition:opacity 1s cubic-bezier(0.5, 0, 0.85, 0.45);opacity:0;}.myshowclass{opacity:1!important;}.onoffswitch{margin:0 15px 0 20px;position:relative;width:55px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;}.onoffswitch-checkbox{display:none;}.onoffswitch-label{display:block;overflow:hidden;cursor:pointer;border:2px solid #999;border-radius:50px;}.onoffswitch-inner{display:block;width:200%;margin-left:-100%;transition:margin 0.3s ease-in 0s;}.onoffswitch-inner:before,.onoffswitch-inner:after{display:block;float:left;width:50%;height:16px;padding:0;line-height:16px;font-size:11px;color:white;font-family:Trebuchet,Arial,sans-serif;font-weight:700;box-sizing:border-box;}.onoffswitch-inner:before{content:'ON';padding-left:5px;background-color:#fff;color:#000;}.onoffswitch-inner:after{content:'OFF';padding-right:5px;background-color:#777;color:#fff;text-align:right;}.onoffswitch-switch{display:block;width:20px;margin:-2px;background:#666;position:absolute;top:0;bottom:0;right:35px;border:2px solid #999;border-radius:50px;transition:all 0.3s ease-in 0s;}.onoffswitch-checkbox:checked+.onoffswitch-label .onoffswitch-inner{margin-left:0;}.onoffswitch-checkbox:checked+.onoffswitch-label .onoffswitch-switch{right:0;background:#fff;}"; document.head.appendChild(myCSS); function revealpopup() { checkplaybackstatus.classList.remove("myfadeoutclass"); checkplaybackstatus.classList.add("myshowclass"); setTimeout(function(){checkplaybackstatus.classList.add("myfadeoutclass");checkplaybackstatus.classList.remove("myshowclass");},100); } function playbackStatus() { return playbackbutton.title.toLowerCase(); } function startchecker() { checkboxinput.checked=true; autocontinue=true; userPauseDetected=false; checkplaybackID = setInterval(function(){ if(autocontinue==false){return;} if(skipcheck){return;} if(userPauseDetected){return;} if( playbackStatus()==pause_text && playbackbutton.hidden==false ){return;} else if ( playbackStatus()==play_text ) { playbackbutton.click(); } },check_playback_interval); checkplaybackstatus.innerText="playback checker: ON"; revealpopup(); } function stopchecker() { checkboxinput.checked=false; autocontinue=false; userPauseDetected=false; clearInterval(checkplaybackID); checkplaybackstatus.innerText="playback checker: OFF"; revealpopup(); } checkboxinput.onclick=function(e){ if(this.checked){ startchecker(); } else { stopchecker(); } clickedButton=true; } window.addEventListener('keyup', function(e) { if (e.code == "KeyX" || e.which == 88) { if (autocontinue) { stopchecker(); } else { startchecker(); } } else { skipcheck=true; setTimeout(function(){ if( playbackStatus()==play_text ) { userPauseDetected=true; } else { userPauseDetected=false; } skipcheck=false; },100); } }); window.addEventListener('mouseup', function(e) { if (e.which == 1) { skipcheck=true; setTimeout(function(){ if (clickedButton) { clickedButton=false; skipcheck=false; return; } if( playbackStatus()==play_text ) { userPauseDetected=true; } else { userPauseDetected=false; } skipcheck=false; },100); } }); var labelappended=false; var checkElementID; function startElementChecker(){ checkElementID = setInterval(function(){ //if(!labelappended){ if ( (typeof(document.querySelector("#left-controls .left-controls-buttons")) == undefined || document.querySelector("#left-controls .left-controls-buttons") == null) ) { return; } var leftcontrolsbuttons = document.querySelector("#left-controls .left-controls-buttons"); leftcontrolsbuttons.appendChild(checkboxdiv); labelappended=true; playbackbutton = document.querySelector("#play-pause-button"); clearInterval(checkElementID); if(autocontinue){ startchecker(); } //} },check_playback_interval); } startElementChecker(); /* https://gf.qytechs.cn/en/scripts/390352  Are you annoyed when youtube music playback suddenly stops, only to find that it asks for your input to make sure you are still there? Install this little script and you'll never have to bother with the "You There? Continue playing?" popup. The script will automatically resume playback. **Features:** - press X to enable/disable auto resuming - popup to show the current status (active or inactive) when X is pressed - button next to the controls to toggle the playback checker complementary to the hotkey <br> **== IMPORTANT ==** - Firefox users, you'll have to allow auto-playing of sounds if you want music to start immediately, see attached picture - Chrome/Opera users, no additional steps are required, but just to be safe you can allow sounds anyway, see attached picture <br> **Disclaimer:** If the 'continue playing popup' appeared, playback may stop for up to 1 second (1000 milliseconds) until it checks again. If you want this gap to be smaller, then change the variable (check_playback_interval) value in the top from 1000 to a lower one. Just remember, the more often it checks the more resources its going to use. */
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址