Ezt a szkriptet nem ajánlott közvetlenül telepíteni. Ez egy könyvtár más szkriptek számára, amik tartalmazzák a // @require https://update.greasyfork.org/scripts/487608/1374594/SyntaxSimplified.js
hivatkozást.
// ==UserScript==
// @name SyntaxSimplified
// @version 2024/05/11
// @author Canaan HS
// @description Library for simplifying code logic and syntax
// @namespace https://greasyfork.org/users/989635
// @match *://*/*
// @license MIT
// ==/UserScript==
class Syntax{constructor(){this.Mark={};this.Parser=new DOMParser;this.ListenerRecord=new Map;this.Buffer=document.createDocumentFragment();this.print={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)};this.query={Match:/[ .#=:]/,"#":(a,c)=>a.getElementById(c.slice(1)),".":(a,c,b)=>{a=a.getElementsByClassName(c.slice(1));return b?[...a]:a[0]},tag:(a,c,b)=>{a=a.getElementsByTagName(c);return b?[...a]:a[0]},"default":(a,c,b)=>b?a.querySelectorAll(c):a.querySelector(c)};this.StorageMatch={Type:a=>Object.prototype.toString.call(a).slice(8,-1),String:(a,c,b)=>null!=b?(a.setItem(c,JSON.stringify(b)),!0):JSON.parse(c),Number:(a,c,b)=>null!=b?(a.setItem(c,JSON.stringify(b)),!0):Number(c),Array:(a,c,b)=>null!=b?(a.setItem(c,JSON.stringify(b)),!0):(c=JSON.parse(c),Array.isArray(c[0])?new Map(c):c),Object:(a,c,b)=>null!=b?(a.setItem(c,JSON.stringify(b)),!0):JSON.parse(c),Boolean:(a,c,b)=>null!=b?(a.setItem(c,JSON.stringify(b)),!0):JSON.parse(c),Date:(a,c,b)=>null!=b?(a.setItem(c,JSON.stringify(b)),!0):new Date(c),Map:(a,c,b)=>(a.setItem(c,JSON.stringify([...b])),!0)};this.Device={sX:()=>window.scrollX,sY:()=>window.scrollY,iW:()=>window.innerWidth,iH:()=>window.innerHeight,Url:()=>location.href,Orig:()=>location.origin,Host:()=>location.hostname,Path:()=>location.pathname,Lang:()=>navigator.language,Agen:()=>navigator.userAgent,_Type:void 0,Type:()=>this.Device._Type=this.Device._Type?this.Device._Type:this.Device._Type=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(this.Device.Agen())||768>this.Device.iW()?"Mobile":"Desktop"}}$$(a,{all:c=!1,root:b=document}={}){const e=this.query.Match.test(a)?this.query.Match.test(a.slice(1))?"default":a[0]:"tag";return this.query[e](b,a,c)}DomParse(a){return this.Parser.parseFromString(a,"text/html")}NameFilter(a){return a.replace(/[\/\?<>\\:\*\|":]/g,"")}GetFill(a){return Math.max(2,`${a}`.length)}ExtensionName(a){try{return a.match(/\.([^.]+)$/)[1].toLowerCase()||"png"}catch{return"png"}}Mantissa(a,c,b="0",e=null){return e?`${++a}.${this.ExtensionName(e)}`.padStart(c,b):`${++a}`.padStart(c,b)}WorkerCreation(a){a=new Blob([a],{type:"application/javascript"});return new Worker(URL.createObjectURL(a))}sleep(a){return new Promise(c=>setTimeout(c,a))}async AddStyle(a,c="New-Style"){let b=document.getElementById(c);b||(b=document.createElement("style"),b.id=c,document.head.appendChild(b));b.textContent+=a}async AddScript(a,c="New-Script"){let b=document.getElementById(c);b||(b=document.createElement("script"),b.id=c,document.head.appendChild(b));b.textContent+=a}async AddListener(a,c,b,e={}){const d=this.ListenerRecord.get(a);d&&d?.has(c)||(a.addEventListener(c,b,e),d||this.ListenerRecord.set(a,new Map),this.ListenerRecord.get(a).set(c,b))}async RemovListener(a,c){const b=this.ListenerRecord.get(a)?.get(c);b&&(a.removeEventListener(c,b),this.ListenerRecord.get(a).delete(c))}async Listen(a,c,b,e={},d=null){try{a.addEventListener(c,b,e),d&&d(!0)}catch{d&&d(!1)}}async Observer(a,c,{mark:b=!1,throttle:e=0,subtree:d=!0,childList:f=!0,characterData:g=!1}={},m=null){if(b){if(this.Mark[b])return;this.Mark[b]=!0}b={subtree:d,childList:f,characterData:g};e=new MutationObserver(this.Throttle(()=>{c()},e));e.observe(a,b);m&&m({ob:e,op:b})}async WaitElem(a,c,{raf:b=!1,all:e=!1,timeout:d=8,throttle:f=50,subtree:g=!0,childList:m=!0,characterData:q=!1,timeoutResult:r=!1,object:p=document.body}={}){let k,h,n;if(b){let l;const t=()=>{h=e?document.querySelectorAll(a):document.querySelector(a);(n=e?0<h.length:h)?(cancelAnimationFrame(l),clearTimeout(k),c(h)):l=requestAnimationFrame(t)};l=requestAnimationFrame(t);k=setTimeout(()=>{cancelAnimationFrame(l);r&&c(h)},1E3*d)}else{const l=new MutationObserver(this.Throttle(()=>{h=e?document.querySelectorAll(a):document.querySelector(a);if(n=e?0<h.length:h)l.disconnect(),clearTimeout(k),c(h)},f));l.observe(p,{subtree:g,childList:m,characterData:q});k=setTimeout(()=>{l.disconnect();r&&c(h)},1E3*d)}}async WaitMap(a,c,{raf:b=!1,timeout:e=8,throttle:d=50,subtree:f=!0,childList:g=!0,characterData:m=!1,timeoutResult:q=!1,object:r=document.body}={}){let p,k;if(b){let h;const n=()=>{k=a.map(l=>document.querySelector(l));k.every(l=>null!==l&&"undefined"!==typeof l)?(cancelAnimationFrame(h),clearTimeout(p),c(k)):h=requestAnimationFrame(n)};h=requestAnimationFrame(n);p=setTimeout(()=>{cancelAnimationFrame(h);q&&c(k)},1E3*e)}else{const h=new MutationObserver(this.Throttle(()=>{k=a.map(n=>document.querySelector(n));k.every(n=>null!==n&&"undefined"!==typeof n)&&(h.disconnect(),clearTimeout(p),c(k))},d));h.observe(r,{subtree:f,childList:g,characterData:m});p=setTimeout(()=>{h.disconnect();q&&c(k)},1E3*e)}}async log(a=null,c="print",{type:b="log",collapsed:e=!0}={}){b="string"===typeof b&&this.print[b]?b:b="log";if(null==a)this.print[b](c);else e?console.groupCollapsed(a):console.group(a),this.print[b](c),console.groupEnd()}Runtime(a=null,c="Elapsed Time:",{style:b="\u001b[1m\u001b[36m%s\u001b[0m",log:e=!0}={}){return a?e?console.log(b,`${c} ${(Date.now()-a)/1E3}s`):Date.now()-a:Date.now()}Debounce(a,c=500){let b=null;return(...e)=>{clearTimeout(b);b=setTimeout(function(){a(...e)},c)}}Throttle(a,c){let b=0;return(...e)=>{const d=Date.now();d-b>=c&&(b=d,a(...e))}}ScopeParsing(a,c){const b=new Set,e=new Set,d=c.length;for(const g of a.split(/\s*[,\.]\s*/))if(/^\d+$/.test(g))b.add(Number(g)-1);else if(/^\d+(?:~\d+|-\d+)$/.test(g)){var f=g.split(/-|~/);a=Number(f[0]-1);f=Number(f[1]-1);const m=a<=f;for(;m?a<=f:a>=f;m?a++:a--)b.add(a)}else/(!|-)+\d+/.test(g)&&e.add(Number(g.slice(1)-1));return[...b].filter(g=>!e.has(g)&&g<d&&0<=g).sort((g,m)=>g-m).map(g=>c[g])}Storage(a,{type:c=sessionStorage,value:b=null,error:e}={}){let d;return null!=b?this.StorageMatch[this.StorageMatch.Type(b)](c,a,b):(d=c.getItem(a),void 0!=d?this.StorageMatch[this.StorageMatch.Type(JSON.parse(d))](c,d):e)}store(a,c=null,b=null){const e={verify:d=>void 0!==d?d:!1,d:d=>GM_deleteValue(d),a:()=>e.verify(GM_listValues()),s:(d,f)=>GM_setValue(d,f),g:(d,f)=>e.verify(GM_getValue(d,f)),sj:(d,f)=>GM_setValue(d,JSON.stringify(f,null,4)),gj:(d,f)=>JSON.parse(e.verify(GM_getValue(d,f)))};return e[a](c,b)}async storeListen(a,c){a.forEach(b=>{this.Mark[b]||(this.Mark[b]=!0,GM_addValueChangeListener(b,function(e,d,f,g){c({key:e,ov:d,nv:f,far:g})}))})}async Menu(a,c="Menu",b=1){for(const [e,d]of Object.entries(a))GM_registerMenuCommand(e,()=>{d.func()},{title:d.desc,id:`${c}-${b++}`,autoClose:d.close,accessKey:d.hotkey})}};