You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
7.2 KiB

(function(){"use strict";const D=e=>typeof e.prev=="function"?e.prev:D(e.prev);var M=(e,n,t)=>{const r=n[e][t];return r===void 0?n[t]:D(r)};class O{constructor(n,t,r){this.data={id:n,func:(o,...i)=>r(o,typeof this.prev=="function"?this.prev:this.prev.data.func,i)},this.prev=t}}var B=(e,n,t,r)=>{const o=e[r][n];if(o.data.id===t){if(typeof o.prev=="function"){e[n]=o.prev,delete e[r][n];return}e[r][n]=o.prev,e[n]=o.prev.data.func;return}const i=a=>a&&typeof a.prev=="object"?(a.data=a.prev.data,a.prev=a.prev.prev,i(a.prev)):!0,f=a=>{if(!a)throw new Error("could not find unpatch");return typeof a.prev=="object"&&a.data.id!==t?f(a.prev):i(a)};let l=Object.assign({},o);f(l),e[r][n]=l,e[n]=l.data.func},T=function(e,n,t,r,o){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof n=="function"?e!==n||!o:!n.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?o.call(e,t):o?o.value=t:n.set(e,t),t},s=function(e,n,t,r){if(t==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof n=="function"?e!==n||!r:!n.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(e):r?r.value:n.get(e)},y,d,m,E;class x{constructor(n="simian"){y.add(this),d.set(this,void 0),m.set(this,void 0),T(this,d,Symbol(n),"f"),T(this,m,new Set,"f"),this.after=s(this,y,"m",E).call(this,"AFTER"),this.before=s(this,y,"m",E).call(this,"BEFORE"),this.instead=s(this,y,"m",E).call(this,"INSTEAD")}cleanupAll(){for(const n of s(this,m,"f")){for(const t in n[s(this,d,"f")]){const r=M(s(this,d,"f"),n,t);n[t]=r,n[s(this,d,"f")][t]=void 0}n[s(this,d,"f")]=void 0,delete n[s(this,d,"f")]}s(this,m,"f").clear()}}d=new WeakMap,m=new WeakMap,y=new WeakSet,E=function(n){return(t,r,o)=>{const i=r[t];if(typeof i!="function")throw new Error(`${t} is not a function on ${r}`);const f=Symbol();r[s(this,d,"f")]===void 0&&(r[s(this,d,"f")]={});let l;switch(n){case"AFTER":l=(h,v,_)=>{let w=v.apply(h,_);const S=o.apply(h,[_,w]);return typeof S!="undefined"&&(w=S),w};break;case"BEFORE":l=(h,v,_)=>{var w;let S=_;const F=(w=o.apply(h,[_]))!==null&&w!==void 0?w:_;return Array.isArray(F)&&(S=F),v.apply(h,S)};break;case"INSTEAD":l=(h,v,_)=>o.apply(h,[_,v.bind(h)]);break}let a=r[s(this,d,"f")][t];return a===void 0?a=new O(f,i,l):a=new O(f,a,l),r[s(this,d,"f")][t]=a,r[t]=function(){return a.data.func(this,...arguments)},Object.assign(r[t],i),s(this,m,"f").add(r),()=>B(r,t,f,s(this,d,"f"))}};function I(){let e={};return window.webpackChunkdiscord_app.push([[Math.random().toString(36)],{},n=>{e=n}]),e.c}function L(e,n){let t=[];for(const r in n){const o=n[r].exports;o&&(o.default&&o.__esModule&&e(o.default)?t.push(o.default):e(o)&&t.push(o))}return t}let p={modules:I(),filter:L,find:e=>p.filter(e,p.modules)[0],findAll:e=>p.filter(e,p.modules),findByProps:(...e)=>p.find(n=>e.every(t=>n[t]!==void 0)),findByPropsAll:(...e)=>p.findAll(n=>e.every(t=>n[t]!==void 0))};function $(){var e=!navigator.userAgentData&&/Safari\//.test(navigator.userAgent)&&!/Chrom(e|ium)\//.test(navigator.userAgent);if(!e||!indexedDB.databases)return Promise.resolve();var n;return new Promise(function(t){var r=function(){return indexedDB.databases().finally(t)};n=setInterval(r,100),r()}).finally(function(){return clearInterval(n)})}function u(e){return new Promise((n,t)=>{e.oncomplete=e.onsuccess=()=>n(e.result),e.onabort=e.onerror=()=>t(e.error)})}function A(e,n){const t=$().then(()=>{const r=indexedDB.open(e);return r.onupgradeneeded=()=>r.result.createObjectStore(n),u(r)});return(r,o)=>t.then(i=>o(i.transaction(n,r).objectStore(n)))}let P;function c(){return P||(P=A("keyval-store","keyval")),P}function g(e,n=c()){return n("readonly",t=>u(t.get(e)))}function b(e,n,t=c()){return t("readwrite",r=>(r.put(n,e),u(r.transaction)))}function U(e,n=c()){return n("readwrite",t=>(e.forEach(r=>t.put(r[1],r[0])),u(t.transaction)))}function W(e,n=c()){return n("readonly",t=>Promise.all(e.map(r=>u(t.get(r)))))}function G(e,n,t=c()){return t("readwrite",r=>new Promise((o,i)=>{r.get(e).onsuccess=function(){try{r.put(n(this.result),e),o(u(r.transaction))}catch(f){i(f)}}}))}function H(e,n=c()){return n("readwrite",t=>(t.delete(e),u(t.transaction)))}function Y(e,n=c()){return n("readwrite",t=>(e.forEach(r=>t.delete(r)),u(t.transaction)))}function z(e=c()){return e("readwrite",n=>(n.clear(),u(n.transaction)))}function R(e,n){return e("readonly",t=>(t.openCursor().onsuccess=function(){!this.result||(n(this.result),this.result.continue())},u(t.transaction)))}function K(e=c()){const n=[];return R(e,t=>n.push(t.key)).then(()=>n)}function J(e=c()){const n=[];return R(e,t=>n.push(t.value)).then(()=>n)}function Q(e=c()){const n=[];return R(e,t=>n.push([t.key,t.value])).then(()=>n)}var V=Object.freeze({__proto__:null,clear:z,createStore:A,del:H,delMany:Y,entries:Q,get:g,getMany:W,keys:K,promisifyRequest:u,set:b,setMany:U,update:G,values:J});const X={React:p.findByProps("__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","createElement"),ReactDOM:p.findByProps("__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED","hydrate"),"idb-keyval":V};function Z(e){e.demon.__commands={},e.demon.patcher.after("sendMessage",e.demon.webpack.findByProps("sendMessage"),(n,t)=>{let r;for(const o of Reflect.ownKeys(e.demon.__commands)){let i=e.demon.__commands[o];if(t[1].content.split(" ")[0]===">"+i.name){r=i.callback(t);break}}return r!==void 0&&(t[1].content=r),t})}function q(e){let n=Symbol(e.name);return window.demon.__commands[n]=e,()=>{delete window.demon.__commands[n]}}var k={add:q,init:Z};async function N(e){return e.demon.__plugins={},!0}async function j(e,n){const t={metadata:n,iife:e,enabled:!1},r=await g("demoncord");return r.plugin[n.name]=t,await b("demoncord",r),!0}async function ee(e){const n=await g("demoncord");return n.plugin[e]===void 0?(console.error("[Demoncord] Cannot remove non-existant plugin!"),!1):(n.plugin[e]=void 0,delete n.plugin[e],await b("demoncord",n),!0)}async function ne(e){const n=await g("demoncord");if(n.plugin[e]===void 0)return console.error("[Demoncord] Cannot start non-existant plugin!"),!1;{console.log(`[Demoncord] Starting ${e}...`);const t=n.plugin[e],o=(0,eval)(t.iife).onStart;let i={};return o(i),console.log(`[Demoncord] Started ${e}!`),window.demon.__plugins[e]={status:1,ctx:i},!0}}async function te(e){const n=await g("demoncord");if(n.plugin[e]===void 0)return console.error("[Demoncord] Cannot stop non-existant or non-running plugin!"),!1;{console.log(`[Demoncord] Stopping ${e}...`);const t=n.plugin[e];return(0,eval)(t.iife).onStop(window.demon.__plugins[e].ctx),console.log(`[Demoncord] Stopped ${e}!`),!0}}var C={init:N,addPlugin:j,delPlugin:ee,startPlugin:ne,stopPlugin:te};async function re(e){const n=new x;e.demon={patcher:{monkeyPatch:function(t,r,o){let[i,f,l]=[()=>{},()=>{},()=>{}];return o.before!==void 0&&(i=n.before(t,r,o.before)),o.instead!==void 0&&(i=n.instead(t,r,o.instead)),o.after!==void 0&&(i=n.after(t,r,o.after)),()=>{i(),f(),l()}},before:n.before,instead:n.instead,after:n.after},webpack:p,common:X,commands:{add:k.add},__DO_NOT_USE_OR_YOU_WILL_BE_FIRED_UNTO_THE_DEPTHS_OF_HELL:{plugins:C}},k.init(e),C.init(e)}window.demon&&delete window.demon,re(window)})();