This script should not be not be installed directly. It is a library for other scripts to include with the meta directive // @require https://update.greasyforks.org/scripts/487608/1666944/SyntaxLite_min.js
// ==UserScript==
// @name SyntaxLite
// @version 2025.09.26
// @author Canaan HS
// @description Library for simplifying code logic and syntax (Lite)
// @namespace https://greasyforks.org/users/989635
// @match *://*/*
// @license MPL-2.0
// ==/UserScript==
const Lib=(()=>{function v(a=document,b,c){if(1!==a?.nodeType&&9!==a?.nodeType)return c?[]:void 0;const e=b[0],d=b.slice(1);if(/[ .#:[\]>+~*,()^$=]/.test(d))return c?a.querySelectorAll(b):a.querySelector(b);if(!c&&"#"===e)return 9===a.nodeType?a.getElementById(d):a.querySelector(b);if("."===b[0])return a=a.getElementsByClassName(d),c?[...a]:a[0];a=a.getElementsByTagName(b);return c?[...a]:a[0]}function P(...a){if(0!==a.length){var b={},c=a,e={dev:!0,group:null,collapsed:!0};if(1<a.length){const h=
a[0],k=a.at(-1),p=h?.constructor===Object,r=k?.constructor===Object;if(r&&!p)b=k,c=a.slice(0,-1);else if(p&&!r)b=h,c=a.slice(1);else if(p&&r){const q=new Set(Object.keys(e));b=Object.keys(h).filter(w=>q.has(w)).length;Object.keys(k).filter(w=>q.has(w)).length>b?(b=k,c=a.slice(0,-1)):(b=h,c=a.slice(1))}}var {dev:d,group:f,collapsed:g}={...e,...b};if(!d||0===c.length)return new Proxy({},{get(){}});var l=h=>{"count"===h?F.count(c[0]):(h=F[h]||F.log,f?(g?console.groupCollapsed(f):console.group(f),h(...c),
console.groupEnd()):h(...c))},m=setTimeout(()=>l("log",c));return new Proxy({},{get(h,k){clearTimeout(m);l(k,c)}})}}async function Q(a,b,c=crypto.randomUUID(),e=!0){if(e||!G.has(c)){var d=document.getElementById(c);d||(d=document.createElement(a),d.id=c,(a=R.head)?a.appendChild(d):S("head").then(f=>{f.appendChild(d)}));d.textContent+=b;G.add(c)}}async function S(a,b=null,c={}){const e=Array.isArray(a)?T.queryMap:T.queryElement,{raf:d=!1,all:f=!1,timeout:g=8,throttle:l=0,debounce:m=50,visibility:h=
!0,subtree:k=!0,childList:p=!0,attributes:r=!0,characterData:q=!1,timeoutResult:w=!1,root:H=document}=c||{};return new Promise((t,n)=>{const C=async function(){let x,u;if(d){let z;const D=()=>{(u=e(a,f))?(cancelAnimationFrame(z),clearTimeout(x),b?.(u),t(u)):z=requestAnimationFrame(D)};z=requestAnimationFrame(D);x=setTimeout(()=>{cancelAnimationFrame(z);w&&(b?.(u),t(u))},1E3*g)}else{const [z,D]=0<l?[I,l]:[J,m],K=new MutationObserver(z(()=>{if(u=e(a,f))K.disconnect(),clearTimeout(x),b?.(u),t(u)},D));
K.observe(H,{subtree:k,childList:p,attributes:r,characterData:q});x=setTimeout(()=>{K.disconnect();w&&(b?.(u),t(u))},1E3*g)}};h&&"hidden"===document.visibilityState?document.addEventListener("visibilitychange",()=>C(),{once:!0}):C()})}function U(a,b,c,e){let d;return null!=c?V[L(c)](b,a,c):(d=b.getItem(a),void 0!=d?V[L(JSON.parse(d))](b,d):e)}function I(a,b){let c=0;return(...e)=>{const d=Date.now();d-c>=b&&(c=d,a(...e))}}function J(a,b){let c=null;return(...e)=>{clearTimeout(c);c=setTimeout(function(){a(...e)},
b)}}const L=a=>Object.prototype.toString.call(a).slice(8,-1);[Document.prototype,Element.prototype].forEach(a=>{a.$q=function(b){return v(this,b,!1)};a.$qa=function(b){return v(this,b,!0)}});const M={$text(a=null){return null===a?this?.textContent?.trim():this.textContent=a?.trim()??""},$copy(a=!0){return this.cloneNode(a)},$iHtml(a=null){return null===a?this.innerHTML:this.innerHTML=a},$oHtml(a=null){return null===a?this.outerHTML:this.outerHTML=a},$iAdjacent(a,b="beforeend"){null!=a&&(1===a.nodeType?
this.insertAdjacentElement(b,a):this.insertAdjacentHTML(b,a))},$sAttr(a,b){this.setAttribute(a,b)},$dAttr(a){this.removeAttribute(a)},$gAttr(a){return this.getAttribute(a)},$hAttr(a){return this.hasAttribute(a)},$addClass(...a){this.classList.add(...a)},$delClass(...a){this.classList.remove(...a)},$toggleClass(a,b){this.classList.toggle(a,b)},$replaceClass(a,b){this.classList.replace(a,b)},$hasClass(a){return this.classList.contains(a)}};Object.assign(Node.prototype,M);const W=Object.keys(M)[0];Object.defineProperty(Object.prototype,
W,{value:function(a=null){return M[W].call(this,a)},writable:!0,configurable:!0});const R={$q:document.$q.bind(document),$Q:(a,b)=>v(a,b,!1),$qa:document.$qa.bind(document),$Qa:(a,b)=>v(a,b,!0),html:document.documentElement,get head(){const a=document.head;a&&Object.defineProperty(this,"head",{value:a,writable:!1});return a},get body(){const a=document.body;a&&Object.defineProperty(this,"body",{value:a,writable:!1});return a},img:document.images,link:document.links,script:document.scripts,style:document.styleSheets,
$url:location.href,get url(){return location.href},$origin:location.origin,get origin(){return location.origin},$domain:location.hostname,get domain(){return location.hostname},$lang:navigator.language,get lang(){return navigator.language},$agen:navigator.userAgent,get agen(){return navigator.userAgent},createDomFragment:a=>document.createRange().createContextualFragment(a),get createFragment(){return document.createDocumentFragment()},title:(a=null)=>null===a?document.title:document.title=a,cookie:(a=
null)=>null===a?document.cookie:document.cookie=a,createUrl:a=>URL.createObjectURL(a),_on:(a,b)=>{const c={};for(const d of Object.keys(b)){let e=b[d];e&&("function"===typeof e&&(e={listen:e}),e.listen&&(a.addEventListener(d,e.listen,e.add),c[d]=()=>a.removeEventListener(d,e.listen,e.add)))}return c},createElement(a,b,c,e){const [d,f,g={},l="beforeend"]="string"===typeof a?[void 0,a,b,c]:[a,b,c,e];if(f){var {class:m,text:h="",rows:k,cols:p,on:r={},style:q={},attr:w={},...H}=g;a=document.createElement(f);a.textContent=
h;m&&(a.className=m);void 0!==k&&(a.rowSpan=k);void 0!==p&&(a.colSpan=p);Object.assign(a,H);"string"===typeof q?a.style.cssText=q:Object.assign(a.style,q);for(const n in w)a.setAttribute(n,w[n]);var t="object"===typeof r&&0<Object.keys(r).length?this._on(a,r):{};Object.assign(a,{on(n,C,x){this.addEventListener(n,C,x);Object.assign(t,{[n]:()=>this.removeEventListener(n,C,x)})},off(n){t[n]?.();delete t[n]},offAll(){Object.keys(t).forEach(n=>{t[n]();delete t[n]})}});return 1===d?.nodeType?d.insertAdjacentElement(l,
a):a}}},A=new Map,F={log:(...a)=>console.log(...a),warn:(...a)=>console.warn(...a),table:(...a)=>console.table(...a),trace:(...a)=>console.trace(...a),debug:(...a)=>console.debug(...a),error:(...a)=>console.error(...a),count:a=>console.count(a)},G=new Set,E=new Map,T={queryMap:(a,b)=>{a=a.map(c=>v(document,c,b));return b?a.every(c=>0<c.length)&&a:a.every(Boolean)&&a},queryElement:(a,b)=>{a=v(document,a,b);return(b?0<a.length:a)&&a}},V={String:(a,b,c)=>null!=c?(a.setItem(b,JSON.stringify(c)),!0):JSON.parse(b),
Number:(a,b,c)=>null!=c?(a.setItem(b,JSON.stringify(c)),!0):Number(b),Array:(a,b,c)=>null!=c?(a.setItem(b,JSON.stringify(c)),!0):(b=JSON.parse(b),Array.isArray(b[0])?new Map(b):b),Object:(a,b,c)=>null!=c?(a.setItem(b,JSON.stringify(c)),!0):JSON.parse(b),Boolean:(a,b,c)=>null!=c?(a.setItem(b,JSON.stringify(c)),!0):JSON.parse(b),Date:(a,b,c)=>null!=c?(a.setItem(b,JSON.stringify(c)),!0):new Date(b),Map:(a,b,c)=>(a.setItem(b,JSON.stringify([...c])),!0)},N={ko:"Korea","ko-KR":"Korea",ja:"Japan","ja-JP":"Japan",
ru:"Russia","ru-RU":"Russia",en:"English","en-US":"English","en-GB":"English","en-AU":"English","en-CA":"English","en-NZ":"English","en-IE":"English","en-ZA":"English","en-IN":"English",zh:"Simplified","zh-CN":"Simplified","zh-SG":"Simplified","zh-MY":"Simplified","zh-TW":"Traditional","zh-HK":"Traditional","zh-MO":"Traditional"},y=new Set,O=a=>void 0===a||null===a?null:a,B=new Map;return function(...a){const b={};for(const c of a)c&&Object.defineProperties(b,Object.getOwnPropertyDescriptors(c));
return b}({get sX(){return window.scrollX},get sY(){return window.scrollY},get iW(){return window.innerWidth},get iH(){return window.innerHeight},_cache:void 0,get platform(){let a;a=void 0!==navigator.userAgentData?.mobile?navigator.userAgentData.mobile?"Mobile":"Desktop":window.matchMedia?.("(max-width: 767px), (pointer: coarse)")?.matches?"Mobile":/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?"Mobile":"Desktop";Object.defineProperty(this,"platform",
{value:a,writable:!1});return a}},R,{addStyle:(a,b,c)=>Q("style",a,b,c),addScript:(a,b,c)=>Q("script",a,b,c),session:(a,{value:b=null,error:c}={})=>U(a,sessionStorage,b,c),local:(a,{value:b=null,error:c}={})=>U(a,localStorage,b,c),delV:a=>GM_deleteValue(a),allV:()=>O(GM_listValues()),setV:(a,b)=>GM_setValue(a,b),getV:(a,b)=>O(GM_getValue(a,b)),setJV:(a,b,c=0)=>GM_setValue(a,JSON.stringify(b,null,c)),getJV(a,b){try{return JSON.parse(O(GM_getValue(a,b)))}catch{return b}},eventRecord:A,addRecord:G,observerRecord:E,
$type:L,onE:async function(a,b,c,e={},d=null){try{"string"===typeof a&&(a=v(document,a));let f=b.split(/\s*[,|/]\s*/).filter(Boolean);if(0===f.length)throw Error("No event types provided");if(1===f.length)a.addEventListener(b,c,e);else{let g=null;const l=m=>{clearTimeout(g);g=setTimeout(()=>c(m),15)};f.forEach(m=>a.addEventListener(m,l,e))}d?.(!0)}catch{d?.(!1)}},onEvent:async function(a,b,c,e={}){const {mark:d,...f}=e;"string"===typeof a&&(a=v(document,a));e=d??a;const g=A.get(e);g?.has(b)||(a.addEventListener(b,
c,f),g||A.set(e,new Map),A.get(e).set(b,c))},offEvent:async function(a,b,c){"string"===typeof a&&(a=v(document,a));c=c??a;const e=A.get(c)?.get(b);e&&(a.removeEventListener(b,e),A.get(c).delete(b))},onUrlChange:function(a,b=15){function c(k){clearTimeout(d);g||"urlchange"!==k||(g=!0);d=setTimeout(()=>{g&&e(!1,!0);a({type:k,url:location.href,domain:location.hostname})},Math.max(15,b))}function e(k=!0,p=!1){p&&f||(clearTimeout(d),history.pushState=l,history.replaceState=m,k&&window.removeEventListener("urlchange",
h.urlchange),window.removeEventListener("popstate",h.popstate),window.removeEventListener("hashchange",h.hashchange),f=!0)}let d=null,f=!1,g=!1;const l=history.pushState,m=history.replaceState,h={urlchange:()=>c("urlchange"),popstate:()=>c("popstate"),hashchange:()=>c("hashchange")};window.addEventListener("urlchange",h.urlchange);window.addEventListener("popstate",h.popstate);window.addEventListener("hashchange",h.hashchange);history.pushState=function(){l.apply(this,arguments);c("pushState")};history.replaceState=
function(){m.apply(this,arguments);c("replacestate")};return{off:e}},log:P,createLog:function(a={}){return(...b)=>P(...b,a)},$observer:async function(a,b,c={},e=null){const {mark:d="",debounce:f=0,throttle:g=100,subtree:l=!0,childList:m=!0,attributes:h=!0,characterData:k=!1}=c||{};if(d&&(c=E.get(d))){if(c.target===a)return;c.ob.disconnect();E.delete(d)}const [p,r]=0<f?[J,f]:[I,g];c={subtree:l,childList:m,attributes:h,characterData:k};const q=new MutationObserver(p(()=>{b()},r));q.observe(a,c);d&&
E.set(d,{target:a,ob:q});e?.({ob:q,op:c})},waitEl:S,$throttle:I,$debounce:J,outputJson:async function(a,b,c=null){try{a="string"===typeof a?a:JSON.stringify(a,null,4);b="string"===typeof b?b.endsWith(".json")?b:`${b}.json`:`Untitled-${crypto.randomUUID().slice(9,23)}.json`;const e=new Blob([a],{type:"application/json"}),d=document.createElement("a");d.href=URL.createObjectURL(e);d.download=b;d.click();URL.revokeObjectURL(d.href);d.remove();c?.({State:!0})}catch(e){c?.({State:!1,Info:e})}},runTime:function(a=
null,{lable:b="Elapsed Time:",log:c=!0,format:e=!0,style:d="\u001b[1m\u001b[36m%s\u001b[0m"}={}){if(!a)return performance.now();a=e?`${((performance.now()-a)/1E3).toPrecision(3)}s`:performance.now()-a;return c?console.log(d,`${b} ${a}`):a},getDate:function(a=null){const b=new Date,c={year:b.getFullYear(),month:`${b.getMonth()+1}`.padStart(2,"0"),date:`${b.getDate()}`.padStart(2,"0"),hour:`${b.getHours()}`.padStart(2,"0"),minute:`${b.getMinutes()}`.padStart(2,"0"),second:`${b.getSeconds()}`.padStart(2,
"0")};return(e=>e.replace(/{([^}]+)}/g,(d,f)=>c[f]??"Error"))("string"===typeof a?a:"{year}-{month}-{date} {hour}:{minute}:{second}")},translMatcher:function(a,b=navigator.language,c="en-US"){return a[N[b]]??a[N[c]]??a[N["en-US"]]},regMenu:function(a,b={}){let {name:c="regMenu",index:e=1,reset:d=!1}=b||{};d&&([...y].map(f=>GM_unregisterMenuCommand(f)),y.clear());for(let [f,g]of Object.entries(a))a=`${c}-${e++}`,"function"===typeof g&&(g={func:g}),GM_registerMenuCommand(f,()=>{g.func()},{id:a,title:g.desc,
autoClose:g.close,accessKey:g.hotkey}),y.add(a)},unMenu:async function(a){null==a?([...y].map(b=>GM_unregisterMenuCommand(b)),y.clear()):Array.isArray(a)?a.forEach(b=>{y.delete(b)&&GM_unregisterMenuCommand(b)}):y.delete(a)&&GM_unregisterMenuCommand(a)},storeListen:function(a,b){a.forEach(c=>{if(!B.has(c)){const e=GM_addValueChangeListener(c,function(d,f,g,l){b({key:d,ov:f,nv:g,far:l})});B.set(c,e)}});return{off(c){const e=B.get(c);e&&(GM_removeValueChangeListener(e),B.delete(c))},offAll(){for(const c of B.values())GM_removeValueChangeListener(c);
B.clear()}}}})})();