您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
bilibili倍速快捷键+记忆(可自定义设置快捷键,自定义一个额外倍速按钮,设置记忆模式)
当前为
// ==UserScript== // @name bilibili倍速快捷键(增强)+记忆 // @namespace tonyu_balabala_03e6ea // @version 1.0 // @description bilibili倍速快捷键+记忆(可自定义设置快捷键,自定义一个额外倍速按钮,设置记忆模式) // @author Tony // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAoVQTFRFAAAAfov/f4v/f4z/f4z/f4z/f4z/f4v/fYr/fov/f4z/f4z/f4z/f4z/f4z/foz/fYv/e4n/f4z/f4z/f4z/fov/eor/for/f4z/f4z/f4z/foz/f4v/eYj/eon/fov/foz/f4z/f4z/f4z/foz/f4z/f4z/fov/d4j/fov/f4z/f4z/fov/foz/f4z/fov/fIz/UWD8UWD8UWD8UWD8q7D/q7D/q7D/fYv/foz/fov/fIn/f4z/QID/UWD8UWD8UWD8q7D/q7D/q7D/q7D/Zmb/f4z/f4z/eYz/f4z/fov/UWD8q7D/q7D/q7D/VYD/f4z/f4z/f4r/f4z/fIv/q7D/for/f4z/fYr/f4z/fov/q7D/q7D/fov/foz/f4z/aoD/q7D/cID/f4z/fYv/f4v/q7D/q7D/q7D/f4z/f4z/fov/UWD8UWD8q7D/q7D/q7D/q7D/q7D/f4v/f4z/fov/UWD8UWD8UWD8f4z/f4z/f4z/e4f/UWD8UWD8d4n/f4z/d4b/UWD8eIf/f4z/f4z/UWD8UWD8UWD8UWD8f4v/f4z/foz/fov/foz/f4z/fYv/f4z/f4z/fIv/f4z/eIf/eYb/f4z/f4z/fov/fov/f4z/foz/f4z/fIr/fIz/f4z/f4z/f4z/cXH/YID/f4z/foz/fYj/f4z/UWD8UWD8f4z/fIn/for/foz/fIz/UWD8UWD8foz/f4z/for/f4v/fov/bW3/cXH/f4z/f4z/foz/f4z/f4z/fov/foz/eYj/eon/foz/f4z/f4z/fov/eIf/f4z/f4z/f4z/f4v/e4T/for/foz/f4z/f4z/f4z/f4v/for/f4v/f4z/f4v/fov/VQ1gSwAAANd0Uk5TAB9fg5SSgVoXFY3Z/v/RgQ4FjPXwewMh1MloNxUEBhg7b9XFLujMOgFG29weH+eFBhjl2xAeRAEJnRQE0ABM/zOU/9E9AIq5A4mDTZn7awCjYxfLBl4J3g6OOfcoV2XdALEB2iBjhP4ckFkxUjcJXGZhCEuCEtS9UBxWkwTk1wdiBcgIYYDBojYLIFVYNE86Gm2aEdYBAuXAgURmWe8JDeZ3nwABulQDw0sypQIWpQnYyrjKDh5QAAHIFBW7kUMbBwhLmeMOAmDt5FIBDGPG/bxZCD9YPBCTjRZGAAACCklEQVR4nJWT+V9MURjGX1FMzaNoUZaULJkSaSRbJzdDSZRE2UJ2lZ1kC9FiT9bKkrKVXUJR1rLv/p7OPXfmujN3/OD55Tzv+3w/n3Pez+c9RP+jLi5du7m6de/hPDW4exghZOzp6aWLe/X2hkY+vn72eR9/3g3o26//gMCBQcGDeBFi0OaDhwBDh4XaytDhJiAs/G8+IgIYOUp2kaOjzGOix1LMOMA03pZPmAgETxI2lrG4yVL8FLJMBaYlWIFEYLqSUxIHZkhS8kyalQKkKs3Z3kibQ3aAJKXT3HnwyRDNTGA+OQILFtIiYLFoZiFkiQ6QltKybKTJveXACtICKwWwajWtAeRB1gLrVCCHsdy89Ru4Nm6izUAQ720BtlJkklDONsa25yveTDuAAg7sBHbRbqbTHtoLFHLAFdhHUXpgPx0AijhwUH6KOU4o9xBjxSWKL6Uy4DAHjgBH1UfmM1aiFseA4/w4AZy0G1MtymE8JZ8VqDjtDDhzFueEOQ9ccAZUAlXCeFUj+6IeuBSByzGKvQLUXHUEauuAa1b2+g0g0SLsTcZuCWPh61DfYLvtdhZw567szPful4prHwAPH6nzUKO8pI+bbOWTIr6kT5+RRs0tfNNNz1+0tr0Mf/X6DS/q35Kd3rV3aD/O+w8fyVGfPn+xfr2v377/0MVChp+/UgsLfv9xnv5Dnauuj5T4NeYmAAAAAElFTkSuQmCC // @license MIT // @match *://*.bilibili.com/* // @grant GM_getValue // @grant GM_setValue // @grant GM_registerMenuCommand // ==/UserScript== (function() { 'use strict'; let hasObserve = false let count = 0 let defaultSpd = 1 let callbackTimer let spdMemoryMode = GM_getValue('tony_spd_memory_mode', '2') let spdKCSettings = [] let spdKCSettingKeys = ['tony_spd2_KC', 'tony_spd1p5_KC', 'tony_spd1p25_KC', 'tony_spd1_KC', 'tony_spd0p75_KC', 'tony_spd0p5_KC', 'tony_spdcus_KC'] let spdKCSettingDefaultVals = [66, 86, 67, 71, 72, 74, 75] let spdKNames = [] let spdKNameKeys = ['tony_spd2_KC_name', 'tony_spd1p5_KC_name', 'tony_spd1p25_KC_name', 'tony_spd1_KC_name', 'tony_spd0p75_KC_name', 'tony_spd0p5_KC_name', 'tony_spdcus_KC_name'] let spdKNameDefaultVals = ['b', 'v', 'c', 'g', 'h', 'j', 'k'] // spd2_KC_enable, spd1p5_KC_enable, spd1p25_KC_enable, spd1_KC_enable, spd0p75_KC_enable, spd0p5_KC_enable let spdEnableSettings = [] let spdEnableSettingKeys = ['tony_spd2_KC_enable', 'tony_spd1p5_KC_enable', 'tony_spd1p25_KC_enable', 'tony_spd1_KC_enable', 'tony_spd0p75_KC_enable', 'tony_spd0p5_KC_enable', 'tony_spdcus_KC_enable'] let spdEnableSettingDefaultVals = [true, true, false, false, false, false, true] for(let i =0;i<spdKCSettingKeys.length;i++) { spdKCSettings.push(GM_getValue(spdKCSettingKeys[i], spdKCSettingDefaultVals[i])) } for(let i =0;i<spdKNameKeys.length;i++) { spdKNames.push(GM_getValue(spdKNameKeys[i], spdKNameDefaultVals[i])) } for(let i= 0;i<spdEnableSettingKeys.length;i++) { spdEnableSettings.push(GM_getValue(spdEnableSettingKeys[i], spdEnableSettingDefaultVals[i])) } let cusSpd = GM_getValue('tony_spd_cus', 3) let speedList = [2, 1.5, 1.25, 1, 0.75, 0.5] speedList.push(cusSpd) let spd = GM_getValue('tony_spd', 1) let bvdos = getVdos() if(bvdos.length>0) defaultSpd = bvdos[0].playbackRate function getVdos() { let vdos = document.getElementsByTagName('bwp-video') if(vdos.length === 0) { vdos = document.getElementsByTagName('video') } return vdos } function getBeisuList() { let beisuList = document.getElementsByClassName("bilibili-player-video-btn-speed-menu-list") if(beisuList.length==0) { beisuList = document.querySelectorAll(".squirtle-speed-select-list>.squirtle-select-item ") } if(beisuList.length==0) { beisuList = document.querySelectorAll(".edu-player-speed-list>.edu-player-speed-item") } if(beisuList.length==0) { beisuList = document.querySelectorAll(".bpx-player-ctrl-playbackrate-menu>.bpx-player-ctrl-playbackrate-menu-item") } return beisuList } function changeSpeed(beisuList, spd) { switch(spd) { case 2: beisuList[0].click() break case 1.5: beisuList[1].click() break case 1.25: beisuList[2].click() break case 1: beisuList[3].click() break case 0.75: beisuList[4].click() break case 0.5: beisuList[5].click() break case cusSpd: beisuList[6].click() break default: break } } function setPlaybackRate1(beisuList, vdo1) { let intervalCount = 0 let myInterval myInterval = setInterval(() => { intervalCount++ if(intervalCount>40 || vdo1.playbackRate === 1) { // 有时候直接点击当前倍速按钮并没有效果,通过先点击1倍速按钮,再点击其他倍速按钮来实现。 let temSpd = spd changeSpeed(beisuList, 1) changeSpeed(beisuList, temSpd) intervalCount = 0 clearInterval(myInterval) } },100) } function initObserver() { let vdos = getVdos() let config = {attributes: true, attributeFilter:['src']} // let listWrapper = document.getElementsByClassName('list-wrapper')[0] // let vdoTitle = document.getElementsByClassName('video-title')[0] // let config1 = {attributes: true, attributeFilter:['class'], subtree: true} // let config2 = {childList: true} function callback(mutationsList, observer) { clearTimeout(callbackTimer) callbackTimer = setTimeout(function() { let vdo1s = getVdos() if(vdo1s.length>0) { let vdo1 = vdo1s[0] let beisuList = getBeisuList() if(beisuList.length>0) { function vdoPlayHandler() { changeSpeed(beisuList, spd) vdo1.removeEventListener('play',vdoPlayHandler) } vdo1.addEventListener('play', vdoPlayHandler) } } },100) } if(vdos.length>0) { const observer = new MutationObserver(callback) observer.observe(vdos[0], config) hasObserve = true } // if(listWrapper) { // const observer1 = new MutationObserver(callback) // observer1.observe(listWrapper, config1) // hasObserve = true // } else if(vdoTitle) { // const observer2 = new MutationObserver(callback) // observer2.observe(vdoTitle, config2) // hasObserve = true // } count++ if(count<=20 && !hasObserve) setTimeout(initObserver, 1000) } //initObserver() // 全局记忆 if(spdMemoryMode==='2') defaultSpd = spd else { spd = defaultSpd GM_setValue('tony_spd',defaultSpd) } let cusBeisuMenu let initSpdCnt = 0 let hasAddVdoListener = false let hasAddMenuListener = false let oldSrc = '' let vdoPlayTimer function initSpeedAndListener() { let beisuList = getBeisuList() initSpdCnt++ let vdos vdos = getVdos() if(spdMemoryMode === '1' || spdMemoryMode === '2' || spdMemoryMode ==='3') { // 尝试持续监听视频play来判断切换 if(vdos.length>0 && !hasAddVdoListener) { vdos[0].addEventListener('play', function() { clearTimeout(vdoPlayTimer) vdoPlayTimer = setTimeout(function() { //视频开始播放 if(oldSrc !== vdos[0].src) { let bsList = getBeisuList() if(bsList.length>0) { // 不知什么原因,部分场景下设置为其他倍速,比如2倍速,切换视频后显示依然是2倍速,但是视频确实1倍速,通过再次点击2倍速来纠正 // 每次初始倍速为1 if(spdMemoryMode === '3') spd = 1 // 默认 当前页面记忆倍速(页面刷新丢失记忆) 或 全局记忆 changeSpeed(bsList, spd) setPlaybackRate1(bsList, vdos[0]) } oldSrc = vdos[0].src } },100) }) vdos[0].addEventListener('canplay', function() { //if(beisuList.length>0) }) hasAddVdoListener = true } } else if(vdos.length>0 && !hasAddVdoListener) { hasAddVdoListener = true } if(beisuList.length>0 && !hasAddMenuListener) { cusBeisuMenu = beisuList[0].cloneNode(true) let settingMenu = document.createElement('li') settingMenu.setAttribute('style', 'text-align: -webkit-match-parent;position: relative;height: 36px;line-height: 36px;cursor: pointer;margin:0;padding:0;') settingMenu.innerText = '设置' settingMenu.addEventListener('click',showSetting) cusBeisuMenu.setAttribute('data-value', cusSpd) cusBeisuMenu.innerText = cusSpd%1>0?(cusSpd+'x'):(cusSpd+'.0x') beisuList[0].parentNode.appendChild(cusBeisuMenu) beisuList[0].parentNode.insertBefore(settingMenu, beisuList[0]) beisuList = getBeisuList() function getMenuClickHandler(i) { return function() { spd = speedList[i] //console.log('spd', spd) GM_setValue('tony_spd',spd) } } for(let i = 0;i<beisuList.length;i++) { beisuList[i].addEventListener('click', getMenuClickHandler(i)) } hasAddMenuListener = true changeSpeed(beisuList, spd) } if(initSpdCnt<=40 && (!hasAddMenuListener || !hasAddVdoListener)) { setTimeout(initSpeedAndListener,500) } if(hasAddMenuListener && hasAddVdoListener) { setPlaybackRate1(beisuList, vdos[0]) } } initSpeedAndListener() // 节流标志 let flag = false document.addEventListener('keydown', function(e){ if(flag) return flag = true setTimeout(() => { flag = false },100) let beisuList = getBeisuList() for(let i=0;i<spdKCSettings.length;i++) { if(e.keyCode == spdKCSettings[i] && beisuList.length!==0) { if(spdEnableSettings[i]) { if(spd === speedList[i]) { beisuList[3].click() } else { beisuList[i].click() } } break } } }); let hasSettingShow = false function showSetting() { if(hasSettingShow) return let settingBox = document.createElement("div"); settingBox.setAttribute("style", `position: fixed !important; top: 10px !important; left: 50% !important; z-index:2147483647 !important; `) let contentBox = document.createElement('div') contentBox.setAttribute("style", `box-shadow: 0 0 10px rgba(100, 100, 100, 0.2) !important; max-height: calc(100vh - 60px) !important; max-width: 80vw !important; overflow: auto !important; background-color: rgb(235, 235, 235) !important; text-align: center !important; font-size: 13px !important; border-radius: 16px !important; white-space: nowrap; padding: 10px 16px 10px 16px !important; margin-left: -50% !important; margin-right: 50% !important; z-index:2147483647 !important; box-sizing: content-box !important; border: 2px solid rgb(100 100 100 / 10%) !important; `) if('backdropFilter' in document.documentElement.style) { contentBox.style.backgroundColor = 'rgba(235, 235, 235, 0.8)' contentBox.style.backdropFilter = 'saturate(50%) blur(14px)' //contentBox.style.transform = 'translateZ(0)' } if(getComputedStyle) { let fontFml = getComputedStyle(document.body, null)['font-family'] if(fontFml) contentBox.style.fontFamily = fontFml } // let logoDiv = document.createElement('div') // logoDiv.setAttribute("style", 'margin-bottom: 6px !important;') // contentBox.appendChild(logoDiv) let settingContent = document.createElement('div') settingContent.setAttribute('style', 'font-weight: 600 !important;') let MemorySettingTitle = document.createElement('div') MemorySettingTitle.setAttribute('style', 'margin-top:10px;') MemorySettingTitle.innerText = '倍速记忆模式' settingContent.appendChild(MemorySettingTitle) let spdMemoryModeSelector = document.createElement('select') spdMemoryModeSelector.setAttribute('style', 'margin-top:10px;padding:3px 10px;border:2px solid rgb(168,168,168);border-radius:10px;') let spdMemoryModeOption1 = document.createElement('option') spdMemoryModeOption1.value = '1' spdMemoryModeOption1.innerText = '仅当前页面记忆倍速' spdMemoryModeOption1.selected = spdMemoryMode==='1' let spdMemoryModeOption2 = document.createElement('option') spdMemoryModeOption2.value = '2' spdMemoryModeOption2.innerText = '全局记忆倍速' spdMemoryModeOption2.selected = spdMemoryMode==='2' let spdMemoryModeOption3 = document.createElement('option') spdMemoryModeOption3.value = '3' spdMemoryModeOption3.innerText = '每次初始倍速为1(不记忆)' spdMemoryModeOption3.selected = spdMemoryMode==='3' let spdMemoryModeOption4 = document.createElement('option') spdMemoryModeOption4.value = '4' spdMemoryModeOption4.innerText = '什么都不做' spdMemoryModeOption4.selected = spdMemoryMode==='4' spdMemoryModeSelector.appendChild(spdMemoryModeOption1) spdMemoryModeSelector.appendChild(spdMemoryModeOption2) spdMemoryModeSelector.appendChild(spdMemoryModeOption3) spdMemoryModeSelector.appendChild(spdMemoryModeOption4) spdMemoryModeSelector.addEventListener('change', function() { spdMemoryMode = spdMemoryModeSelector.value GM_setValue('tony_spd_memory_mode', spdMemoryMode) }) settingContent.appendChild(spdMemoryModeSelector) let cusSpdTitle = document.createElement('div') cusSpdTitle.setAttribute('style', 'margin-top:10px;') cusSpdTitle.innerText = '自定义倍速键设置(0~4)' settingContent.appendChild(cusSpdTitle) let cusSpdSettingBox = document.createElement('div') cusSpdSettingBox.setAttribute('style', 'margin-top:10px;') let cusSpdSettingBtnBox = document.createElement('div') cusSpdSettingBtnBox.setAttribute('style', 'display:none;margin-top:8px;') let cusSpdSettingBtnOK = document.createElement('button') let cusSpdSettingBtnCancel = document.createElement('button') let cusSpdInput = document.createElement('input') cusSpdInput.setAttribute('type', 'number') cusSpdInput.setAttribute('style', 'max-width:100px;padding:5px 10px;border:2px solid rgb(168,168,168);border-radius:10px;') cusSpdInput.value = cusSpd let oldCusSpd cusSpdInput.addEventListener('focus', function() { oldCusSpd = cusSpd cusSpdSettingBtnBox.style.display = 'block' }) cusSpdSettingBtnOK.innerText = '确认' cusSpdSettingBtnOK.setAttribute('style', 'padding:8px 10px;border:0;color:white;background-color:rgb(25,207,20);border-radius:28px;') cusSpdSettingBtnOK.addEventListener('click', function() { let temCusSpd = parseFloat(cusSpdInput.value) if(!temCusSpd || temCusSpd<=0 || temCusSpd>4) { cusSpdInput.value = cusSpd cusSpdSettingBtnBox.style.display = 'none' return } cusSpd = temCusSpd GM_setValue('tony_spd_cus', cusSpd) speedList[speedList.length-1] = cusSpd if(cusBeisuMenu) { cusBeisuMenu.setAttribute('data-value', cusSpd) cusBeisuMenu.innerText = cusSpd%1>0?(cusSpd+'x'):(cusSpd+'.0x') } speedSettingBtns[speedSettingBtns.length-1].innerText = cusSpd if(speedSettingBtns[speedSettingBtns.length-1].style.backgroundColor === 'rgb(50, 130, 236)') speedSettingBtns[speedSettingBtns.length-1].click() cusSpdSettingBtnBox.style.display = 'none' }) cusSpdSettingBtnCancel.innerText = '取消' cusSpdSettingBtnCancel.setAttribute('style', 'margin-right:6px;padding:8px 10px;border:0;color:white;background-color:rgb(243,97,128);border-radius:28px;') cusSpdSettingBtnCancel.addEventListener('click', function() { cusSpdInput.value = cusSpd cusSpdSettingBtnBox.style.display = 'none' }) cusSpdSettingBox.appendChild(cusSpdInput) cusSpdSettingBtnBox.appendChild(cusSpdSettingBtnCancel) cusSpdSettingBtnBox.appendChild(cusSpdSettingBtnOK) cusSpdSettingBox.appendChild(cusSpdSettingBtnBox) settingContent.appendChild(cusSpdSettingBox) let KCSettingTitle = document.createElement('div') KCSettingTitle.setAttribute('style', 'margin-top:10px;') KCSettingTitle.innerText = '倍速快捷键设置' settingContent.appendChild(KCSettingTitle) let KCBox = document.createElement('div') KCBox.setAttribute('style', 'margin-top:10px;') let settingBtnBox = document.createElement('div') settingBtnBox.setAttribute('style', 'margin-top:10px;') let speedSettingBtns = [] for(let i = 0; i < speedList.length; i++) { let speedSettingBtn = document.createElement('button') speedSettingBtns.push(speedSettingBtn) speedSettingBtn.setAttribute('style', 'margin:0 3px;padding:8px 10px;min-width:38px;border:0;color:white;background-color:rgb(100,100,100);border-radius:28px;') speedSettingBtn.innerText = speedList[i] speedSettingBtn.addEventListener('click', function() { for(let j = 0; j<speedList.length;j++) { if(j===i) speedSettingBtns[j].style.backgroundColor = 'rgb(50,130,236)' else speedSettingBtns[j].style.backgroundColor = 'rgb(100,100,100)' } let KCSwitch = document.createElement('input') KCSwitch.setAttribute('style', 'vertical-align: middle;') let switchTip = document.createElement('span') switchTip.setAttribute('style', 'vertical-align: middle;') KCSwitch.setAttribute('type', 'checkbox') KCSwitch.checked = spdEnableSettings[i] switchTip.innerText = speedList[i]+'倍速快捷键 '+(spdEnableSettings[i]?'启用':'关闭') KCSwitch.addEventListener('change', function() { spdEnableSettings[i] = KCSwitch.checked switchTip.innerText = speedList[i]+'倍速快捷键 '+(spdEnableSettings[i]?'启用':'关闭') GM_setValue(spdEnableSettingKeys[i], KCSwitch.checked) }) let KCSettingBox = document.createElement('div') KCSettingBox.setAttribute('style', 'margin-top:10px;') let KNameTitle = document.createElement('span') KNameTitle.innerText = speedList[i]+'倍速快捷键(点击修改→):' KNameTitle.setAttribute('style', 'margin-right:6px;') let KCSettingBtnBox = document.createElement('div') KCSettingBtnBox.setAttribute('style', 'display:none;margin-top:8px;') let KCSettingBtnOK = document.createElement('button') let KCSettingBtnCancel = document.createElement('button') let KName = document.createElement('button') KName.innerText = spdKNames[i] KName.setAttribute('style', 'padding:8px 16px;border-radius:28px;color:rgb(5,107,0);background-color:rgb(240,240,240);border:1px solid rgb(100,100,100);') let clickSpdKC = spdKCSettings[i] let clickSpdKName = spdKNames[i] function keyupHandler(e) { e.stopPropagation() clickSpdKC = e.keyCode clickSpdKName = e.key KName.innerText = clickSpdKName } function kNameClickHandler() { clickSpdKC = spdKCSettings[i] clickSpdKName = spdKNames[i] KName.innerText = '请按键ヾ(•ω•`)o' KName.addEventListener('keydown', keyupHandler) KName.removeEventListener('click', kNameClickHandler) KCSettingBtnBox.style.display = 'block' KName.focus() } KName.addEventListener('click', kNameClickHandler) KCSettingBtnOK.innerText = '确认' KCSettingBtnOK.setAttribute('style', 'padding:8px 10px;border:0;color:white;background-color:rgb(25,207,20);border-radius:28px;') KCSettingBtnOK.addEventListener('click', function() { spdKCSettings[i] = clickSpdKC spdKNames[i] = clickSpdKName GM_setValue(spdKCSettingKeys[i], clickSpdKC) GM_setValue(spdKNameKeys[i], clickSpdKName) KName.innerText = spdKNames[i] KName.removeEventListener('keydown', keyupHandler) KName.addEventListener('click', kNameClickHandler) KCSettingBtnBox.style.display = 'none' }) KCSettingBtnCancel.innerText = '取消' KCSettingBtnCancel.setAttribute('style', 'margin-right:6px;padding:8px 10px;border:0;color:white;background-color:rgb(243,97,128);border-radius:28px;') KCSettingBtnCancel.addEventListener('click', function() { KName.innerText = spdKNames[i] // let clickSpdKC = spdKCSettings[i] // let clickSpdKName = spdKNames[i] KName.removeEventListener('keydown', keyupHandler) KName.addEventListener('click', kNameClickHandler) KCSettingBtnBox.style.display = 'none' }) KCSettingBox.appendChild(KNameTitle) KCSettingBox.appendChild(KName) KCSettingBtnBox.appendChild(KCSettingBtnCancel) KCSettingBtnBox.appendChild(KCSettingBtnOK) KCSettingBox.appendChild(KCSettingBtnBox) KCBox.innerHTML = '' KCBox.appendChild(switchTip) KCBox.appendChild(KCSwitch) KCBox.appendChild(KCSettingBox) }) settingBtnBox.appendChild(speedSettingBtn) } settingContent.appendChild(settingBtnBox) settingContent.appendChild(KCBox) let hideBtnBox = document.createElement('div') hideBtnBox.setAttribute('style', 'margin-top:10px;') let hideBtn = document.createElement('button') hideBtn.innerText = '关闭面板' hideBtn.setAttribute('style', 'padding:8px 10px;border:0;color:white;background-color:rgb(50,130,236);border-radius:28px;') hideBtn.addEventListener('click', function() { document.documentElement.removeChild(settingBox) hasSettingShow = false }) hideBtnBox.appendChild(hideBtn) settingContent.appendChild(hideBtnBox) let settingTip = document.createElement('div') settingTip.setAttribute('style', 'margin-top:10px;') settingTip.innerText = '设置完成后刷新页面,以确保生效' settingContent.appendChild(settingTip) contentBox.appendChild(settingContent) settingBox.appendChild(contentBox) document.documentElement.appendChild(settingBox) hasSettingShow = true speedSettingBtns[0].click() } GM_registerMenuCommand('设置',showSetting) })();