SyntaxLite

Library for simplifying code logic and syntax (Lite)

As of 29.04.2025. See ბოლო ვერსია.

ეს სკრიპტი არ უნდა იყოს პირდაპირ დაინსტალირებული. ეს ბიბლიოთეკაა, სხვა სკრიპტებისთვის უნდა ჩართეთ მეტა-დირექტივაში // @require https://update.greatest.deepsurf.us/scripts/487608/1580134/SyntaxLite.js.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         SyntaxLite
// @version      2025/04/30
// @author       Canaan HS
// @description  Library for simplifying code logic and syntax (Lite)
// @namespace    https://greatest.deepsurf.us/users/989635
// @match        *://*/*
// @license      MPL-2.0
// ==/UserScript==
const Syn=(()=>{function r(a=document,b,c){const e=b[0],d=b.slice(1);if(/[ #.\[:]/.test(d))return c?a.querySelectorAll(b):a.querySelector(b);if(!c&&"#"===e)return document.getElementById(d);if("."===b[0])return a=a.getElementsByClassName(d),c?[...a]:a[0];a=a.getElementsByTagName(b);return c?[...a]:a[0]}async function K(a,b,c,e){let d=document.getElementById(c);if(!d)d=document.createElement(a),d.id=c,document.head.appendChild(d);else if(!e)return;d.textContent+=b}function L(a,b,c,e){let d;return null!=c?M[C(c)](b,a,c):(d=b.getItem(a),void 0!=d?M[C(JSON.parse(d))](b,d):e)}function D(a,b){let c=0;return(...e)=>{const d=Date.now();d-c>=b&&(c=d,a(...e))}}function E(a,b){let c=null;return(...e)=>{clearTimeout(c);c=setTimeout(function(){a(...e)},b)}}const y={},C=a=>Object.prototype.toString.call(a).slice(8,-1);[Document.prototype,Element.prototype].forEach(a=>{a.$q=function(b){return r(this,b,!1)};a.$qa=function(b){return r(this,b,!0)}});const F={$text(a=null){return null!==a?this.textContent=a?.trim():this.textContent?.trim()},$copy(a=!0){return this.cloneNode(a)},$iHtml(a=null){return null!==a?this.innerHTML=a:this.innerHTML},$oHtml(a=null){return null!==a?this.outerHTML=a:this.outerHTML},$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,F);const N=Object.keys(F)[0];Object.defineProperty(Object.prototype,N,{value:function(a=null){return F[N].call(this,a)},writable:!0,configurable:!0});const R={$q:document.$q.bind(document),$qa:document.$qa.bind(document),html:document.documentElement,head:document.head,body:document.body,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},get createFragment(){return document.createDocumentFragment()},title:(a=null)=>null!==a?document.title=a:document.title,cookie:(a=null)=>null!==a?document.cookie=a:document.cookie,createUrl:a=>URL.createObjectURL(a),createElement(a,b,c){const [e,d,g={}]="string"===typeof a?[null,a,b]:[a,b,c];if(d){var {id:f,title:k,class:m,text:h="",rows:n,cols:q,style:t={},attr:u={},...z}=g,l=Object.assign(document.createElement(d),{textContent:h});f&&(l.id=f);k&&(l.title=k);m&&(l.className=m);void 0!==n&&(l.rowSpan=n);void 0!==q&&(l.colSpan=q);Object.assign(l,z);Object.assign(l.style,"string"===typeof t?{cssText:t}:t);Object.entries(u).forEach(([v,O])=>l.setAttribute(v,O));return e instanceof HTMLElement?e.appendChild(l):l}}},x=new Map,P={log:a=>console.log(a),warn:a=>console.warn(a),trace:a=>console.trace(a),error:a=>console.error(a),count:a=>console.count(a)};var S=(a,b)=>{a=a.map(c=>r(document,c,b));return b?a.every(c=>0<c.length)&&a:a.every(Boolean)&&a},T=(a,b)=>{a=r(document,a,b);return(b?0<a.length:a)&&a};const M={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)},G={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"},H=new Set,I=a=>void 0===a||null===a?null:a;return{sX:()=>window.scrollX,sY:()=>window.scrollY,iW:()=>window.innerWidth,iH:()=>window.innerHeight,_Cache:void 0,Platform:function(){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},...R,AddStyle:(a,b,c=!0)=>K("style",a,b,c),AddScript:(a,b,c=!0)=>K("script",a,b,c),Session:(a,{value:b=null,error:c}={})=>L(a,sessionStorage,b,c),Local:(a,{value:b=null,error:c}={})=>L(a,localStorage,b,c),dV:a=>GM_deleteValue(a),lV:()=>I(GM_listValues()),sV:(a,b)=>GM_setValue(a,b),gV:(a,b)=>I(GM_getValue(a,b)),sJV:(a,b,c=0)=>GM_setValue(a,JSON.stringify(b,null,c)),gJV:(a,b)=>{try{return JSON.parse(I(GM_getValue(a,b)))}catch{return b}},Type:C,one:async function(a,b,c,e={},d=null){try{let g=b.split(/\s*[,|/]\s*/).filter(Boolean),f=null,k=1<g.length?15:0;const m=h=>{clearTimeout(f);f=setTimeout(()=>c(h),k)};"string"===typeof a&&(a=r(document,a));g.forEach(h=>a.addEventListener(h,m,e));d&&d(!0)}catch{d&&d(!1)}},onEvent:async function(a,b,c,e={}){const {mark:d,...g}=e;"string"===typeof a&&(a=r(document,a));e=d??a;const f=x.get(e);f?.has(b)||(a.addEventListener(b,c,g),f||x.set(e,new Map),x.get(e).set(b,c))},offEvent:async function(a,b,c){"string"===typeof a&&(a=r(document,a));c=c??a;const e=x.get(c)?.get(b);e&&(a.removeEventListener(b,e),x.get(c).delete(b))},onUrlChange:function(a,b=15){function c(n){clearTimeout(d);f||"urlchange"!==n||(f=!0);d=setTimeout(()=>{f&&e(!1,!0);a({type:n,url:location.href,domain:location.hostname})},Math.max(15,b))}function e(n=!0,q=!1){q&&g||(clearTimeout(d),history.pushState=k,history.replaceState=m,n&&window.removeEventListener("urlchange",h.urlchange),window.removeEventListener("popstate",h.popstate),window.removeEventListener("hashchange",h.hashchange),g=!0)}let d=null,g=!1,f=!1;const k=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(){k.apply(this,arguments);c("pushState")};history.replaceState=function(){m.apply(this,arguments);c("replacestate")};return{off:e}},Log:async function(a=null,b="print",{dev:c=!0,type:e="log",collapsed:d=!0}={}){c&&(c=P[e]||P.log,null==a?c(b):(d?console.groupCollapsed(a):console.group(a),c(b),console.groupEnd()))},Observer:async function(a,b,c={},e=null){const {mark:d="",debounce:g=0,throttle:f=100,subtree:k=!0,childList:m=!0,attributes:h=!0,characterData:n=!1}=c??{};if(d){if(y[d])return;y[d]=!0}const [q,t]=0<g?[E,g]:[D,f];c={subtree:k,childList:m,attributes:h,characterData:n};const u=new MutationObserver(q(()=>{b()},t));u.observe(a,c);e&&e({ob:u,op:c})},WaitElem:async function(a,b=null,c={}){const e=Array.isArray(a)?S:T,{raf:d=!1,all:g=!1,timeout:f=8,throttle:k=0,debounce:m=50,visibility:h=!0,subtree:n=!0,childList:q=!0,attributes:t=!0,characterData:u=!1,timeoutResult:z=!1,root:l=document}=c??{};return new Promise((v,O)=>{const Q=async function(){let A,p;if(d){let w;const B=()=>{(p=e(a,g))?(cancelAnimationFrame(w),clearTimeout(A),b&&b(p),v(p)):w=requestAnimationFrame(B)};w=requestAnimationFrame(B);A=setTimeout(()=>{cancelAnimationFrame(w);z&&(b&&b(p),v(p))},1E3*f)}else{const [w,B]=0<k?[D,k]:[E,m],J=new MutationObserver(w(()=>{if(p=e(a,g))J.disconnect(),clearTimeout(A),b&&b(p),v(p)},B));J.observe(l,{subtree:n,childList:q,attributes:t,characterData:u});A=setTimeout(()=>{J.disconnect();z&&(b&&b(p),v(p))},1E3*f)}};h&&"hidden"===document.visibilityState?document.addEventListener("visibilitychange",()=>Q(),{once:!0}):Q()})},Throttle:D,Debounce:E,OutputJson:async function(a,b,c=null){try{a="string"!==typeof a?JSON.stringify(a,null,4):a;b="string"!==typeof b?"Anonymous.json":b.endsWith(".json")?b:`${b}.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&&c({State:!0})}catch(e){c&&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,g)=>c[g]??"Error"))("string"===typeof a?a:"{year}-{month}-{date} {hour}:{minute}:{second}")},TranslMatcher:function(a,b=navigator.language,c="en-US"){return a[G[b]]??a[G[c]]??a[G["en-US"]]},Menu:async function(a,b={}){let {name:c="Menu",index:e=1,reset:d=!1}=b??{};d&&([...H].map(g=>GM_unregisterMenuCommand(g)),H.clear());for(let [g,f]of Object.entries(a))a=`${c}-${e++}`,"function"===typeof f&&(f={func:f}),GM_registerMenuCommand(g,()=>{f.func()},{id:a,title:f.desc,autoClose:f.close,accessKey:f.hotkey}),H.add(a)},StoreListen:async function(a,b){a.forEach(c=>{y[c]||(y[c]=!0,GM_addValueChangeListener(c,function(e,d,g,f){b({key:e,ov:d,nv:g,far:f})}))})}}})();