// ==UserScript==
// @name GrammarSimplified
// @version 2024/03/04
// @author HentaiSaru
// @description Simple syntax simplification function
// @namespace https://greasyfork.org/users/989635
// @match *://*/*
// ==/UserScript==
class API{constructor(){this.ListenerRecord=new Map;this.Parser=new DOMParser;this.GM={__verify:a=>void 0!==a?a:null,set:function(a,b){GM_setValue(a,b)},get:function(a,b){return this.__verify(GM_getValue(a,b))},setjs:function(a,b){GM_setValue(a,JSON.stringify(b,null,4))},getjs:function(a,b){return JSON.parse(this.__verify(GM_getValue(a,b)))}};this.Template={log:a=>console.log(a),warn:a=>console.warn(a),error:a=>console.error(a),count:a=>console.count(a)}}$$(a,b=!1,c=document){const d=a.slice(1);switch([".","#"," ","="].some(e=>d.includes(e))?" ":a[0]){case "#":return c.getElementById(d);case " ":return b?c.querySelectorAll(a):c.querySelector(a);case ".":a=c.getElementsByClassName(d);break;default:a=c.getElementsByTagName(a)}return b?Array.from(a):a[0]}DomParse(a){return this.Parser.parseFromString(a,"text/html")}IllegalCharacters(a){return a.replace(/[\/\?<>\\:\*\|":]/g,"")}ExtensionName(a){try{return a.match(/\.([^.]+)$/)[1].toLowerCase()||"png"}catch{return"png"}}WorkerCreation(a){a=new Blob([a],{type:"application/javascript"});return new Worker(URL.createObjectURL(a))}sleep(a){return new Promise(b=>setTimeout(b,1E3*a))}async AddStyle(a,b="New-Style"){let c=document.getElementById(b);c||((c=document.createElement("style")).id=b,document.head.appendChild(c));c.appendChild(document.createTextNode(a))}async AddScript(a,b="New-Script"){let c=document.getElementById(b);c||((c=document.createElement("script")).id=b,document.head.appendChild(c));c.appendChild(document.createTextNode(a))}async AddListener(a,b,c,d={}){this.ListenerRecord.has(a)&&this.ListenerRecord.get(a).has(b)||(a.addEventListener(b,c,d),this.ListenerRecord.has(a)||this.ListenerRecord.set(a,new Map),this.ListenerRecord.get(a).set(b,c))}async RemovListener(a,b){var c;this.ListenerRecord.has(a)&&this.ListenerRecord.get(a).has(b)&&(c=this.ListenerRecord.get(a).get(b),a.removeEventListener(b,c),this.ListenerRecord.get(a).delete(b))}async Listen(a,b,c,d={},e=null){try{a.addEventListener(b,c,d),e&&e(!0)}catch{e&&e(!1)}}async WaitElem(a,b,c,d,e=document.body){let h,f;const g=new MutationObserver(()=>{f=b?document.querySelectorAll(a):document.querySelector(a);(b?0<f.length&&Array.from(f).every(k=>null!=k):f)&&(g.disconnect(),clearTimeout(h),d(f))});g.observe(e,{childList:!0,subtree:!0});h=setTimeout(()=>{g.disconnect()},1E3*c)}async WaitMap(a,b,c,d=document.body){let e,h;const f=new MutationObserver(()=>{(h=a.map(g=>document.querySelector(g))).every(g=>null!==g&&"string")&&(f.disconnect(),clearTimeout(e),c(h))});f.observe(d,{childList:!0,subtree:!0});e=setTimeout(()=>{f.disconnect()},1E3*b)}async log(a=null,b="print",c="log"){c="string"==typeof c&&this.Template[c]?c:"log";null==a?this.Template[c](b):(console.groupCollapsed(a),this.Template[c](b),console.groupEnd())}store(a,b,c=null){switch(a[0]){case "g":return this.GM[a](b,c);case "s":return null!==c?this.GM[a](b,c):null;default:return Error("wrong type of operation")}}async Menu(a){for(const [b,c]of Object.entries(a))GM_registerMenuCommand(b,()=>{c()})}};