12 |
- // @license MIT
- const features=Object.freeze({arrowKeySupport:!0,themeColor:"#0f0"}),info=Object.freeze({name:GM.info.script.name,version:GM.info.script.version,namespace:GM.info.script.namespace});function init(){console.log(`${info.name} v${info.version} - ${info.namespace}`),document.addEventListener("DOMContentLoaded",onDomLoad)}function onDomLoad(){document.addEventListener("keydown",onKeyDown),"#f00"!=features.themeColor&&"#ff0000"!=features.themeColor&&applyTheme()}function onKeyDown(e){if(features.arrowKeySupport&&["ArrowLeft","ArrowRight"].includes(e.code))switch(e.code){case"ArrowLeft":document.body.dispatchEvent(new KeyboardEvent("keydown",{altKey:!1,bubbles:!0,cancelBubble:!1,cancelable:!0,charCode:0,code:"KeyH",composed:!0,ctrlKey:!1,currentTarget:null,defaultPrevented:e.defaultPrevented,explicitOriginalTarget:document.body,isTrusted:!0,key:"h",keyCode:72,metaKey:!1,originalTarget:document.body,repeat:!1,shiftKey:!1,srcElement:document.body,target:document.body,type:"keydown",view:window,which:72}));break;case"ArrowRight":document.body.dispatchEvent(new KeyboardEvent("keydown",{altKey:!1,bubbles:!0,cancelBubble:!1,cancelable:!0,charCode:0,code:"KeyL",composed:!0,ctrlKey:!1,currentTarget:null,defaultPrevented:e.defaultPrevented,explicitOriginalTarget:document.body,isTrusted:!0,key:"l",keyCode:76,metaKey:!1,originalTarget:document.body,repeat:!1,shiftKey:!1,srcElement:document.body,target:document.body,type:"keydown",view:window,which:76}));break;default:console.warn("Unknown key",e.code)}}function applyTheme(){const e=features.themeColor.match(/^(\d{3}){1,2}$/)?`#${e}`:e;[{elem:document.querySelector("#progressContainer > #primaryProgress"),prop:"background",important:!1},{elem:document.querySelector(),prop:"",important:!1},{elem:document.querySelector(),prop:"",important:!1}].forEach((o=>{if(o.elem){const t=!0===o.important?`${e} !important`:e;o.elem.style[o.prop]=t}}))}init();
|