SyntaxLite

Library for simplifying code logic and syntax (Lite)

Stan na 30-09-2025. Zobacz najnowsza wersja.

Ten skrypt nie powinien być instalowany bezpośrednio. Jest to biblioteka dla innych skyptów do włączenia dyrektywą meta // @require https://update.greasyfork.org/scripts/487608/1669599/SyntaxLite.js

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         SyntaxLite
// @version      2025.10.01
// @author       Canaan HS
// @description  Library for simplifying code logic and syntax (Lite)
// @namespace    https://greasyfork.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 R(...a){if(0!==a.length){var b={},c=a,e={dev:!0,group:null,collapsed:!0};if(1<a.length){const h=
a[0],m=a.at(-1),p=h?.constructor===Object,r=m?.constructor===Object;if(r&&!p)b=m,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(m).filter(w=>q.has(w)).length>b?(b=m,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 k=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))},l=setTimeout(()=>k("log",c));return new Proxy({},{get(h,m){clearTimeout(l);k(m,c)}})}}async function S(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=H.head)?a.appendChild(d):T("head").then(f=>{f.appendChild(d)}));d.textContent+=b;G.add(c)}}async function T(a,b=null,c={}){const e=Array.isArray(a)?U.queryMap:U.queryElement,{raf:d=!1,all:f=!1,timeout:g=8,throttle:k=0,debounce:l=50,visibility:h=
!0,subtree:m=!0,childList:p=!0,attributes:r=!0,characterData:q=!1,timeoutResult:w=!1,root:I=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<k?[J,k]:[K,l],L=new MutationObserver(z(()=>{if(u=e(a,f))L.disconnect(),clearTimeout(x),b?.(u),t(u)},D));
L.observe(I,{subtree:m,childList:p,attributes:r,characterData:q});x=setTimeout(()=>{L.disconnect();w&&(b?.(u),t(u))},1E3*g)}};h&&"hidden"===document.visibilityState?document.addEventListener("visibilitychange",()=>C(),{once:!0}):C()})}function Y(a){if(!a||!a.trim())return 0;if(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(a)){var b=(new Date(a)).getTime();if(!isNaN(b))return Math.floor(b/1E3)}b=new Date;var c=[...a.matchAll(/(\d+)\s*([YyMDdhms])/g)];if(0===c.length)return 0;var e=a=0,d=0,f=0,g=0,k=
0;for(const l of c){c=parseInt(l[1],10);const h=l[2];switch(h.toLowerCase()){case "y":a+=c;break;case "d":d+=c;break;case "h":f+=c;break;case "s":k+=c;break;default:"M"===h?e+=c:"m"===h&&(g+=c)}}b.setFullYear(b.getFullYear()+a);b.setMonth(b.getMonth()+e);b.setDate(b.getDate()+d);b.setHours(b.getHours()+f);b.setMinutes(b.getMinutes()+g);b.setSeconds(b.getSeconds()+k);return Math.floor(b.getTime()/1E3)}function M(a,b,c,{space:e=0,expireStr:d}={}){const f=N(c);c={type:f,value:Z[f]?.(c)??c};(d=Y(d))&&
(c.expire=d);a(b,JSON.stringify(c,null,e))}function O(a,b,c,{autoRemove:e=!1,removeer:d}={}){a=a(b);if(null==a)return c;try{a=JSON.parse(a);const f=a instanceof Object;if(f&&a.expire&&Date.now()>1E3*a.expire)return d(b),c;let g,k;f?(g=a.type??"Object",k=a.value??a):(g=N(a),k=a);const l=aa[g]?.(k)??k;e&&d(b);return l}catch{return"object"===typeof a&&H.isEmpty(a)||"string"===typeof a&&a.startsWith("[object")?c:a}}function J(a,b){let c=0;return(...e)=>{const d=Date.now();d-c>=b&&(c=d,a(...e))}}function K(a,
b){let c=null;return(...e)=>{clearTimeout(c);c=setTimeout(function(){a(...e)},b)}}const ba=new DOMParser,N=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 P={$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,P);const V=Object.keys(P)[0];Object.defineProperty(Object.prototype,V,{value:function(a=null){return P[V].call(this,a)},writable:!0,configurable:!0});const H={$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},isEmpty(a){for(const b in a)return!1;return!0},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 e of Object.keys(b)){let d=b[e];d&&("function"===typeof d&&(d={listen:d}),d.listen&&(a.addEventListener(e,d.listen,d.add),c[e]=()=>a.removeEventListener(e,d.listen,d.add)))}return c},createElement(a,b,c,e){const [d,f,g={},k="beforeend"]="string"===typeof a?
[void 0,a,b,c]:[a,b,c,e];if(f){var {class:l,text:h="",rows:m,cols:p,on:r={},style:q={},attr:w={},...I}=g;a=document.createElement(f);a.textContent=h;l&&(a.className=l);void 0!==m&&(a.rowSpan=m);void 0!==p&&(a.colSpan=p);Object.assign(a,I);"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||this.isEmpty(r)?{}: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(k,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,U={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}},aa={Set:a=>new Set(a),Map:a=>new Map(a),Date:a=>new Date(a)},Z={Set:a=>a instanceof Set?[...a]:a,Map:a=>a instanceof Map?[...a]:a,Date:a=>a instanceof Date?a.toISOString():a},W=localStorage.removeItem.bind(localStorage),ca=localStorage.setItem.bind(localStorage),da=localStorage.getItem.bind(localStorage),X=sessionStorage.removeItem.bind(sessionStorage),ea=sessionStorage.setItem.bind(sessionStorage),fa=sessionStorage.getItem.bind(sessionStorage),
Q={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,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},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}},H,{addStyle:(a,b,c)=>S("style",a,b,c),addScript:(a,b,c)=>S("script",a,b,c),delLocal:a=>W(a),setLocal:(a,b,c)=>M(ca,a,b,{expireStr:c}),getLocal:(a,b,c)=>O(da,a,b,{autoRemove:c,removeer:W}),delSession:a=>X(a),setSession:(a,b,c)=>M(ea,a,b,{expireStr:c}),getSession:(a,b,c)=>O(fa,a,b,{autoRemove:c,removeer:X}),delV:a=>GM_deleteValue(a),allV:()=>{var a=GM_listValues();return null==a?null:a},setV:(a,b)=>GM_setValue(a,b),getV:(a,b)=>{a=GM_getValue(a,b);return null==a?null:a},setJV:(a,b,c=0,e)=>
M(GM_setValue,a,b,{space:c,expireStr:e}),getJV:(a,b,c)=>O(GM_getValue,a,b,{autoRemove:c,removeer:GM_deleteValue}),eventRecord:A,addRecord:G,observerRecord:E,$type:N,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 k=l=>{clearTimeout(g);g=setTimeout(()=>c(l),15)};f.forEach(l=>a.addEventListener(l,k,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(m){clearTimeout(d);g||"urlchange"!==m||(g=!0);d=setTimeout(()=>{g&&e(!1,!0);a({type:m,url:location.href,domain:location.hostname})},
Math.max(15,b))}function e(m=!0,p=!1){p&&f||(clearTimeout(d),history.pushState=k,history.replaceState=l,m&&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 k=history.pushState,l=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(){k.apply(this,arguments);c("pushState")};history.replaceState=function(){l.apply(this,arguments);c("replacestate")};return{off:e}},log:R,createLog:function(a={}){return(...b)=>R(...b,a)},$observer:async function(a,b,c={},e=null){const {mark:d="",debounce:f=0,throttle:g=100,subtree:k=!0,childList:l=!0,attributes:h=!0,characterData:m=!1}=c||{};if(d&&(c=E.get(d))){if(c.target===a)return;c.ob.disconnect();E.delete(d)}const [p,
r]=0<f?[K,f]:[J,g];c={subtree:k,childList:l,attributes:h,characterData:m};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:T,$throttle:J,$debounce:K,createWorker:function(a){a=new Blob([a],{type:"application/javascript"});const b=URL.createObjectURL(a),c=new Worker(b),e=c.terminate;c.terminate=function(){e.call(c);URL.revokeObjectURL(b)};return c},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[Q[b]]??a[Q[c]]??a[Q["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)},storageListen:function(a,b){a.forEach(c=>{if(!B.has(c)){const e=GM_addValueChangeListener(c,function(d,f,g,k){b({key:d,ov:f,nv:g,far:k})});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()}}},sleep:a=>new Promise(b=>setTimeout(b,a)),domParse:a=>ba.parseFromString(a,"text/html")})})();