Object_Syntax.min

Library for simplifying code logic and syntax (Object Type)

Versione datata 18/05/2024. Vedi la nuova versione l'ultima versione.

Questo script non dovrebbe essere installato direttamente. È una libreria per altri script da includere con la chiave // @require https://update.greasyfork.org/scripts/495339/1378689/Object_Syntaxmin.js

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Object_Syntax.min
// @version      2024/05/18
// @author       Canaan HS
// @description  Library for simplifying code logic and syntax (Object Type)
// @namespace    https://greasyfork.org/users/989635
// @match        *://*/*
// @license      MIT
// ==/UserScript==
const Syn=(()=>{const z={},B=new DOMParser,r=new Map,x={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)},y={Match:a=>/[ .#=:]/.test(a),"#":(a,b)=>a.getElementById(b.slice(1)),".":(a,b,c)=>{a=a.getElementsByClassName(b.slice(1));return c?[...a]:a[0]},tag:(a,b,c)=>{a=a.getElementsByTagName(b);return c?[...a]:a[0]},"default":(a,b,c)=>c?a.querySelectorAll(b):a.querySelector(b)},t={verify:a=>void 0!==a?a:!1,d:a=>GM_deleteValue(a),a:()=>t.verify(GM_listValues()),s:(a,b)=>GM_setValue(a,b),g:(a,b)=>t.verify(GM_getValue(a,b)),sj:(a,b)=>GM_setValue(a,JSON.stringify(b,null,4)),gj:(a,b)=>JSON.parse(t.verify(GM_getValue(a,b)))},u={Type:a=>Object.prototype.toString.call(a).slice(8,-1),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)};return{Device:{sX:()=>window.scrollX,sY:()=>window.scrollY,iW:()=>window.innerWidth,iH:()=>window.innerHeight,_Type:void 0,Url:location.href,Orig:location.origin,Host:location.hostname,Path:location.pathname,Lang:navigator.language,Agen:navigator.userAgent,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:b=!1,root:c=document}={})=>{const d=y.Match(a)?y.Match(a.slice(1))?"default":a[0]:"tag";return y[d](c,a,b)},Sleep:a=>new Promise(b=>setTimeout(b,a)),Log:async(a=null,b="print",{type:c="log",collapsed:d=!0}={})=>{c="string"===typeof c&&x[c]?c:c="log";if(null==a)x[c](b);else d?console.groupCollapsed(a):console.group(a),x[c](b),console.groupEnd()},AddStyle:async(a,b="New-Style")=>{let c=document.getElementById(b);c||(c=document.createElement("style"),c.id=b,document.head.appendChild(c));c.textContent+=a},AddScript:async(a,b="New-Script")=>{let c=document.getElementById(b);c||(c=document.createElement("script"),c.id=b,document.head.appendChild(c));c.textContent+=a},Listen:async(a,b,c,d={},e=null)=>{try{a.addEventListener(b,c,d),e&&e(!0)}catch{e&&e(!1)}},AddListener:async(a,b,c,d={})=>{const e=r.get(a);e&&e?.has(b)||(a.addEventListener(b,c,d),e||r.set(a,new Map),r.get(a).set(b,c))},RemovListener:(a,b)=>{const c=r.get(a)?.get(b);c&&(a.removeEventListener(b,c),r.get(a).delete(b))},Observer:async function(a,b,{mark:c=!1,throttle:d=0,subtree:e=!0,childList:h=!0,attributes:f=!0,characterData:m=!1}={},p=null){if(c){if(z[c])return;z[c]=!0}c={subtree:e,childList:h,attributes:f,characterData:m};d=new MutationObserver(this.Throttle(()=>{b()},d));d.observe(a,c);p&&p({ob:d,op:c})},WaitElem:async function(a,b,{raf:c=!1,all:d=!1,timeout:e=8,throttle:h=50,subtree:f=!0,childList:m=!0,attributes:p=!1,characterData:v=!1,timeoutResult:w=!1,object:q=document.body}={}){let k,g,n;if(c){let l;const A=()=>{g=d?document.querySelectorAll(a):document.querySelector(a);(n=d?0<g.length:g)?(cancelAnimationFrame(l),clearTimeout(k),b(g)):l=requestAnimationFrame(A)};l=requestAnimationFrame(A);k=setTimeout(()=>{cancelAnimationFrame(l);w&&b(g)},1E3*e)}else{const l=new MutationObserver(this.Throttle(()=>{g=d?document.querySelectorAll(a):document.querySelector(a);if(n=d?0<g.length:g)l.disconnect(),clearTimeout(k),b(g)},h));l.observe(q,{subtree:f,childList:m,attributes:p,characterData:v});k=setTimeout(()=>{l.disconnect();w&&b(g)},1E3*e)}},async WaitMap(a,b,{raf:c=!1,timeout:d=8,throttle:e=50,subtree:h=!0,childList:f=!0,attributes:m=!1,characterData:p=!1,timeoutResult:v=!1,object:w=document.body}={}){let q,k;if(c){let g;const n=()=>{k=a.map(l=>document.querySelector(l));k.every(l=>null!==l&&"undefined"!==typeof l)?(cancelAnimationFrame(g),clearTimeout(q),b(k)):g=requestAnimationFrame(n)};g=requestAnimationFrame(n);q=setTimeout(()=>{cancelAnimationFrame(g);v&&b(k)},1E3*d)}else{const g=new MutationObserver(this.Throttle(()=>{k=a.map(n=>document.querySelector(n));k.every(n=>null!==n&&"undefined"!==typeof n)&&(g.disconnect(),clearTimeout(q),b(k))},e));g.observe(w,{subtree:h,childList:f,attributes:m,characterData:p});q=setTimeout(()=>{g.disconnect();v&&b(k)},1E3*d)}},Storage(a,{type:b=sessionStorage,value:c=null,error:d}={}){let e;return null!=c?u[u.Type(c)](b,a,c):(e=b.getItem(a),void 0!=e?u[u.Type(JSON.parse(e))](b,e):d)},DomParse:a=>B.parseFromString(a,"text/html"),NameFilter:a=>a.replace(/[\/\?<>\\:\*\|":]/g,""),GetFill:a=>Math.max(2,`${a}`.length),ExtensionName:a=>{try{return a.match(/\.([^.]+)$/)[1].toLowerCase()||"png"}catch{return"png"}},Mantissa:function(a,b,c="0",d=null){return d?`${++a}`.padStart(b,c)+`.${this.ExtensionName(d)}`:`${++a}`.padStart(b,c)},ScopeParsing:(a,b)=>{const c=new Set,d=new Set,e=b.length;for(const f of a.split(/\s*[,\./]\s*/))if(/^\d+$/.test(f))c.add(Number(f)-1);else if(/^\d+(?:~\d+|-\d+)$/.test(f)){var h=f.split(/-|~/);a=Number(h[0]-1);h=Number(h[1]-1);const m=a<=h;for(;m?a<=h:a>=h;m?a++:a--)c.add(a)}else/(!|-)+\d+/.test(f)&&d.add(Number(f.slice(1)-1));return[...c].filter(f=>!d.has(f)&&f<e&&0<=f).sort((f,m)=>f-m).map(f=>b[f])},WorkerCreation:a=>{a=new Blob([a],{type:"application/javascript"});return new Worker(URL.createObjectURL(a))},Runtime:(a=null,b="Elapsed Time:",{style:c="\u001b[1m\u001b[36m%s\u001b[0m",log:d=!0}={})=>a?d?console.log(c,`${b} ${(Date.now()-a)/1E3}s`):Date.now()-a:Date.now(),Throttle:(a,b)=>{let c=0;return(...d)=>{const e=Date.now();e-c>=b&&(c=e,a(...d))}},Debounce:(a,b=500)=>{let c=null;return(...d)=>{clearTimeout(c);c=setTimeout(function(){a(...d)},b)}},Menu:async(a,b="Menu",c=1)=>{for(const [d,e]of Object.entries(a))GM_registerMenuCommand(d,()=>{e.func()},{title:e.desc,id:`${b}-${c++}`,autoClose:e.close,accessKey:e.hotkey})},Store:(a,b=null,c=null)=>t[a](b,c),StoreListen:async(a,b)=>{a.forEach(c=>{this.Mark[c]||(this.Mark[c]=!0,GM_addValueChangeListener(c,function(d,e,h,f){b({key:d,ov:e,nv:h,far:f})}))})}}})();