SyntaxLite

Library for simplifying code logic and syntax (Lite)

Устаревшая версия за 12.09.2025. Перейдите к последней версии.

Этот скрипт недоступен для установки пользователем. Он является библиотекой, которая подключается к другим скриптам мета-ключом // @require https://update.greasyfork.org/scripts/487608/1659706/SyntaxLite.js

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey, Greasemonkey или Violentmonkey.

Для установки этого скрипта вам необходимо установить расширение, такое как Tampermonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

// ==UserScript==
// @name         SyntaxLite
// @version      2025.09.09
// @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 Q(...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),r=h?.constructor===Object,t=k?.constructor===Object;if(t&&!r)b=k,c=a.slice(0,-1);else if(r&&!t)b=h,c=a.slice(1);else if(r&&t){const u=new Set(Object.keys(e));b=Object.keys(h).filter(y=>u.has(y)).length;Object.keys(k).filter(y=>u.has(y)).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 m=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))},p=setTimeout(()=>m("log",c));return new Proxy({},{get(h,k){clearTimeout(p);m(k,c)}})}}async function R(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):S("head").then(f=>{H.head=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:m=0,debounce:p=50,visibility:h=
!0,subtree:k=!0,childList:r=!0,attributes:t=!0,characterData:u=!1,timeoutResult:y=!1,root:I=document}=c||{};return new Promise((l,w)=>{const n=async function(){let x,q;if(d){let A;const D=()=>{(q=e(a,f))?(cancelAnimationFrame(A),clearTimeout(x),b?.(q),l(q)):A=requestAnimationFrame(D)};A=requestAnimationFrame(D);x=setTimeout(()=>{cancelAnimationFrame(A);y&&(b?.(q),l(q))},1E3*g)}else{const [A,D]=0<m?[J,m]:[K,p],L=new MutationObserver(A(()=>{if(q=e(a,f))L.disconnect(),clearTimeout(x),b?.(q),l(q)},D));
L.observe(I,{subtree:k,childList:r,attributes:t,characterData:u});x=setTimeout(()=>{L.disconnect();y&&(b?.(q),l(q))},1E3*g)}};h&&"hidden"===document.visibilityState?document.addEventListener("visibilitychange",()=>n(),{once:!0}):n()})}function U(a,b,c,e){let d;return null!=c?V[M(c)](b,a,c):(d=b.getItem(a),void 0!=d?V[M(JSON.parse(d))](b,d):e)}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 M=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 N={$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,N);const W=Object.keys(N)[0];Object.defineProperty(Object.prototype,
W,{value:function(a=null){return N[W].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,head:document.head??v(document,"head",!1),body:document.body??v(document,"body",!1),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,{type:b,listener:c,
add:e})=>"string"===typeof b&&"function"===typeof c?(a.addEventListener(b,c,e),{[b]:()=>a.removeEventListener(b,c,e)}):{},createElement(a,b,c){const [e,d,f={}]="string"===typeof a?[null,a,b]:[a,b,c];if(d){var {id:g,title:m,class:p,text:h="",rows:k,cols:r,on:t={},style:u={},attr:y={},...I}=f,l=Object.assign(document.createElement(d),{textContent:h});g&&(l.id=g);m&&(l.title=m);p&&(l.className=p);void 0!==k&&(l.rowSpan=k);void 0!==r&&(l.colSpan=r);Object.assign(l,I);Object.assign(l.style,"string"===
typeof u?{cssText:u}:u);Object.entries(y).forEach(([n,x])=>l.setAttribute(n,x));var w={};Array.isArray(t)?t.forEach(n=>Object.assign(w,this._on(l,n))):"object"===typeof t&&Object.assign(w,this._on(l,t));Object.assign(l,{on(n,x,q){this.addEventListener(n,x,q);Object.assign(w,{[n]:()=>this.removeEventListener(n,x,q)})},off(n){w[n]?.();delete w[n]},offAll(){Object.keys(w).forEach(n=>{w[n]();delete w[n]})}});return 1===e?.nodeType?e.appendChild(l):l}}},B=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)},O={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"},z=new Set,P=a=>void 0===a||null===a?null:a,C=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(){this._cache||(void 0!==navigator.userAgentData?.mobile?this._cache=navigator.userAgentData.mobile?"Mobile":"Desktop":window.matchMedia?.("(max-width: 767px), (pointer: coarse)")?.matches?this._cache="Mobile":/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)?this._cache="Mobile":this._cache="Desktop");return this._cache}},H,{addStyle:(a,b,c)=>R("style",a,b,c),
addScript:(a,b,c)=>R("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:()=>P(GM_listValues()),setV:(a,b)=>GM_setValue(a,b),getV:(a,b)=>P(GM_getValue(a,b)),setJV:(a,b,c=0)=>GM_setValue(a,JSON.stringify(b,null,c)),getJV(a,b){try{return JSON.parse(P(GM_getValue(a,b)))}catch{return b}},eventRecord:B,addRecord:G,observerRecord:E,$type:M,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 m=p=>{clearTimeout(g);g=setTimeout(()=>c(p),15)};f.forEach(p=>a.addEventListener(p,m,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=B.get(e);g?.has(b)||(a.addEventListener(b,c,f),g||B.set(e,new Map),B.get(e).set(b,c))},
offEvent:async function(a,b,c){"string"===typeof a&&(a=v(document,a));c=c??a;const e=B.get(c)?.get(b);e&&(a.removeEventListener(b,e),B.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,r=!1){r&&f||(clearTimeout(d),history.pushState=m,history.replaceState=p,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 m=history.pushState,p=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(){m.apply(this,arguments);c("pushState")};history.replaceState=function(){p.apply(this,arguments);
c("replacestate")};return{off:e}},log:Q,createLog:function(a={}){return(...b)=>Q(...b,a)},$observer:async function(a,b,c={},e=null){const {mark:d="",debounce:f=0,throttle:g=100,subtree:m=!0,childList:p=!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 [r,t]=0<f?[K,f]:[J,g];c={subtree:m,childList:p,attributes:h,characterData:k};const u=new MutationObserver(r(()=>{b()},t));u.observe(a,c);d&&E.set(d,{target:a,ob:u});e?.({ob:u,
op:c})},waitEl:S,$throttle:J,$debounce:K,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[O[b]]??a[O[c]]??a[O["en-US"]]},regMenu:function(a,b={}){let {name:c="regMenu",index:e=1,reset:d=!1}=b||{};d&&([...z].map(f=>GM_unregisterMenuCommand(f)),z.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}),
z.add(a)},unMenu:async function(a){null==a?([...z].map(b=>GM_unregisterMenuCommand(b)),z.clear()):Array.isArray(a)?a.forEach(b=>{z.delete(b)&&GM_unregisterMenuCommand(b)}):z.delete(a)&&GM_unregisterMenuCommand(a)},storeListen:function(a,b){a.forEach(c=>{if(!C.has(c)){const e=GM_addValueChangeListener(c,function(d,f,g,m){b({key:d,ov:f,nv:g,far:m})});C.set(c,e)}});return{off(c){const e=C.get(c);e&&(GM_removeValueChangeListener(e),C.delete(c))},offAll(){for(const c of C.values())GM_removeValueChangeListener(c);
C.clear()}}}})})();