SyntaxLite

Library for simplifying code logic and syntax (Lite)

Version vom 18.04.2025. Aktuellste Version

Dieses Skript sollte nicht direkt installiert werden. Es handelt sich hier um eine Bibliothek für andere Skripte, welche über folgenden Befehl in den Metadaten eines Skriptes eingebunden wird // @require https://updategf.qytechs.cn/scripts/487608/1573223/SyntaxLite.js

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey 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.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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/18
// @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 Syn=(()=>{function x(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[D(c)](b,a,c):(d=b.getItem(a),void 0!=d?M[D(JSON.parse(d))](b,d):e)}function E(a,b){let c=0;return(...e)=>{const d=Date.now();d-c>=b&&(c=d,a(...e))}}function F(a,b){let c=null;return(...e)=>{clearTimeout(c);c=setTimeout(function(){a(...e)},b)}}const y={},v=new Map,D=a=>Object.prototype.toString.call(a).slice(8,-1);[Document.prototype,Element.prototype].forEach(a=>{a.$q=function(b){return x(this,b,!1)};a.$qa=function(b){return x(this,b,!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,$origin:location.origin,$domain:location.hostname,$lang:navigator.language,$agen:navigator.userAgent,$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),$createFragment:()=>document.createDocumentFragment(),$createElement:(a,b,c)=>{const [e,d,f={}]="string"===typeof a?[null,a,b]:[a,b,c];if(d){var {id:k,title:l,class:n,text:w="",rows:p,cols:q,style:m={},attr:r={},...z}=f,g=Object.assign(document.createElement(d),{textContent:w});k&&(g.id=k);l&&(g.title=l);n&&(g.className=n);void 0!==p&&(g.rowSpan=p);void 0!==q&&(g.colSpan=q);Object.assign(g,z);Object.assign(g.style,"string"===typeof m?{cssText:m}:m);Object.entries(r).forEach(([t,N])=>g.setAttribute(t,N));return e instanceof HTMLElement?e.appendChild(g):g}}},A={$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)}},G={$one(a,b,c={},e=null){try{this.addEventListener(a,b,c),e&&e(!0)}catch{e&&e(!1)}},$onEvent(a,b,c={}){const {mark:e,...d}=c;c=e??this;const f=v.get(c);f?.has(a)||(this.addEventListener(a,b,d),f||v.set(c,new Map),v.get(c).set(a,b))},$offEvent(a,b){b=b??this;const c=v.get(b)?.get(a);c&&(this.removeEventListener(a,c),v.get(b).delete(a))}};Object.assign(window,G);Object.assign(Node.prototype,A);Object.assign(EventTarget.prototype,G);const O=Object.keys(A)[0];Object.defineProperty(Object.prototype,O,{value:function(a=null){return A[O].call(this,a)},writable:!0,configurable:!0});const 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=>{a=a.map(b=>x(document,b));return a.every(Boolean)&&a},T=(a,b)=>{a=x(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)},H={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"},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,ElementFunctions:Object.keys(A),EventFunctions:Object.keys(G),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:D,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:f=0,throttle:k=100,subtree:l=!0,childList:n=!0,attributes:w=!0,characterData:p=!1}=c??{};if(d){if(y[d])return;y[d]=!0}const [q,m]=0<f?[F,f]:[E,k];c={subtree:l,childList:n,attributes:w,characterData:p};const r=new MutationObserver(q(()=>{b()},m));r.observe(a,c);e&&e({ob:r,op:c})},WaitElem:async function(a,b=null,c={}){const e=Array.isArray(a)?S:T,{raf:d=!1,all:f=!1,timeout:k=8,throttle:l=0,debounce:n=50,visibility:w=!0,subtree:p=!0,childList:q=!0,attributes:m=!0,characterData:r=!1,timeoutResult:z=!1,root:g=document}=c??{};return new Promise((t,N)=>{const Q=async function(){let B,h;if(d){let u;const C=()=>{(h=e(a,f))?(cancelAnimationFrame(u),clearTimeout(B),b&&b(h),t(h)):u=requestAnimationFrame(C)};u=requestAnimationFrame(C);B=setTimeout(()=>{cancelAnimationFrame(u);z&&(b&&b(h),t(h))},1E3*k)}else{const [u,C]=0<l?[E,l]:[F,n],J=new MutationObserver(u(()=>{if(h=e(a,f))J.disconnect(),clearTimeout(B),b&&b(h),t(h)},C));J.observe(g,{subtree:p,childList:q,attributes:m,characterData:r});B=setTimeout(()=>{J.disconnect();z&&(b&&b(h),t(h))},1E3*k)}};w&&"hidden"===document.visibilityState?document.addEventListener("visibilitychange",()=>Q(),{once:!0}):Q()})},Throttle:E,Debounce:F,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,f)=>c[f]??"Error"))("string"===typeof a?a:"{year}-{month}-{date} {hour}:{minute}:{second}")},TranslMatcher:function(a,b,c="en-US"){return a[H[b]]??a[H[c]]??a[H["en-US"]]},Menu:async function(a,b="Menu",c=1){for(const [e,d]of Object.entries(a))GM_registerMenuCommand(e,()=>{d.func()},{title:d.desc,id:`${b}-${c++}`,autoClose:d.close,accessKey:d.hotkey})},StoreListen:async function(a,b){a.forEach(c=>{y[c]||(y[c]=!0,GM_addValueChangeListener(c,function(e,d,f,k){b({key:e,ov:d,nv:f,far:k})}))})}}})();