Merge pull request 'Merge cleanup branch into master' (#3) from cleanup into master

Reviewed-on: #3
master
Drake 2 years ago
commit 3991729857

2
dist/build.js vendored

File diff suppressed because one or more lines are too long

@ -1,7 +1,5 @@
#Passes configuration directly into rollup-plugin-jscc, refer to it's documentation for more details #Passes configuration directly into rollup-plugin-jscc, refer to it's documentation for more details
[values] [values]
_DEBUG = 0 #enables debug logs _DEBUG = 0 #enables debug logs
_ANALYTICS = 0 #enables analytics nagging
_TOKEN = 0 #enables the valentino token logging easter egg (untested, no clue if it actually works)
_CORS_URL = "https://cors.ruthenic.com/" _CORS_URL = "https://cors.ruthenic.com/"

@ -16,17 +16,13 @@
"idb-keyval": "^6.2.0", "idb-keyval": "^6.2.0",
"nests": "^2.3.1", "nests": "^2.3.1",
"rollup-plugin-jscc": "^2.0.0", "rollup-plugin-jscc": "^2.0.0",
"rollup-plugin-visualizer": "^5.7.0", "rollup-plugin-visualizer": "^5.7.0"
"spitroast": "^1.4.2",
"tslib": "^2.4.0"
}, },
"devDependencies": { "devDependencies": {
"@rollup/plugin-alias": "^3.1.9", "@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-node-resolve": "^13.3.0", "@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-typescript": "^8.4.0",
"@swc/core": "^1.2.215", "@swc/core": "^1.2.215",
"rollup": "^2.73.0", "rollup": "^2.73.0",
"rollup-plugin-swc3": "^0.3.0", "rollup-plugin-swc3": "^0.3.0"
"typescript": "^4.8.2"
} }
} }

@ -8,7 +8,6 @@ import { visualizer } from "rollup-plugin-visualizer";
import TOML from "@ltd/j-toml"; import TOML from "@ltd/j-toml";
import jscc from "rollup-plugin-jscc"; import jscc from "rollup-plugin-jscc";
import { readFileSync as readFile, existsSync as fileExists } from "fs"; import { readFileSync as readFile, existsSync as fileExists } from "fs";
import typescript from "@rollup/plugin-typescript";
const projectRootDir = resolvePath(__dirname); const projectRootDir = resolvePath(__dirname);
@ -49,7 +48,6 @@ export default defineConfig({
} }
] ]
}), }),
typescript(),
nodeResolve(), nodeResolve(),
swc({ swc({
jsc: { jsc: {

@ -1,9 +0,0 @@
import modals from "./utils/modals";
/* demon.summon("utils/modals").openConfirmModal("Test Modal", "confirm", {
header: "Demoncord"
}) */
export default {
init: () => {}
};

@ -30,8 +30,7 @@ function wackyPatch(
if (before !== undefined) before.apply(ctx, [args]); if (before !== undefined) before.apply(ctx, [args]);
const res = const res =
patches["instead"] !== undefined patches["instead"] !== undefined
? //@ts-ignore; TS thinks that `instead` possibly being undefined is bad (meanwhile we literally check for that) ? instead?.apply(ctx, [args, target.bind(ctx)])
instead.apply(ctx, [args, target.bind(ctx)])
: target.apply(ctx, args); : target.apply(ctx, args);
if (after === undefined) return res; if (after === undefined) return res;
return after.apply(ctx, [args, res]); return after.apply(ctx, [args, res]);

@ -2,14 +2,15 @@ import webpack from "./webpack";
import { instead } from "./patcher"; import { instead } from "./patcher";
import { leak } from "./utils/memory"; import { leak } from "./utils/memory";
type Sins = Record<string, (() => void) | null>; type Sins = Record<string, () => void>;
type Rulers = Record<string, string>;
const sins: Sins = { const sins: Sins = {
Lust: null, Lust: () => {},
Pride: null, Pride: () => {},
Greed: null, Greed: () => {},
Wrath: null, Wrath: () => {},
Envy: null, Envy: () => {},
Gluttony: () => { Gluttony: () => {
//slowly memory leak to make the app notably slower (perhaps even slothier) //slowly memory leak to make the app notably slower (perhaps even slothier)
setInterval(() => { setInterval(() => {
@ -33,7 +34,7 @@ const sins: Sins = {
} }
}; };
const rulers = { const rulers: Rulers = {
Asmodeus: "Lust", Asmodeus: "Lust",
Lucifer: "Pride", Lucifer: "Pride",
Mammon: "Greed", Mammon: "Greed",
@ -50,12 +51,10 @@ function ritualFail(sin: string) {
throw `Illegal Invocation of a sin!`; throw `Illegal Invocation of a sin!`;
} else { } else {
if (sin in sins) { if (sin in sins) {
if (!sins[sin]) { sins[sin] ||
throw `Illegal Invocation of a sin!`; (() => {
} else { throw `Illegal Invocation of a sin!`;
//@ts-ignore })();
sins[sin]();
}
} else { } else {
console.log("WTF did you do"); console.log("WTF did you do");
console.log(sin); console.log(sin);
@ -96,7 +95,7 @@ function findByRitual(incantation: string) {
Math.floor(Math.random() * Object.keys(sins).length) Math.floor(Math.random() * Object.keys(sins).length)
] ]
); );
return; throw `Illegal Invocation of a sin!`;
} }
if (args.shift() !== "of") { if (args.shift() !== "of") {
ritualFail( ritualFail(
@ -104,9 +103,10 @@ function findByRitual(incantation: string) {
Math.floor(Math.random() * Object.keys(sins).length) Math.floor(Math.random() * Object.keys(sins).length)
] ]
); );
throw `Illegal Invocation of a sin!`;
} }
//@ts-expect-error 2532
const sin = args.shift().replace(",", ""); const sin = args.shift()?.replace(",", "") ?? "";
if (!(sin in sins)) { if (!(sin in sins)) {
//invalid sin, so we can't use it //invalid sin, so we can't use it
ritualFail( ritualFail(
@ -114,62 +114,66 @@ function findByRitual(incantation: string) {
Math.floor(Math.random() * Object.keys(sins).length) Math.floor(Math.random() * Object.keys(sins).length)
] ]
); );
return; throw `Illegal Invocation of a sin!`;
} }
//@ts-expect-error 2532
const ruler = args.shift().replace(",", ""); const ruler = args.shift()?.replace(",", "") ?? "";
if (!(ruler in rulers)) { if (!(ruler in rulers)) {
//invalid ruler, so we still can't use it //invalid ruler, so we still can't use it
//use the sin punishment //use the sin punishment
ritualFail(sin); ritualFail(sin);
throw `Illegal Invocation of a sin!`;
} }
//@ts-expect-error 2532
if (rulers[ruler] !== sin) { if (rulers[ruler] !== sin) {
//sin/ruler mismatch //sin/ruler mismatch
//i feel it's more fitting to call the sin of the demon, instead of the sin you provided, as you would've angered the ruler for calling them for the wrong sin //i feel it's more fitting to call the sin of the demon, instead of the sin you provided, as you would've angered the ruler for calling them for the wrong sin
//@ts-expect-error 2532
ritualFail(rulers[ruler]); ritualFail(rulers[ruler]);
throw `Illegal Invocation of a sin!`;
} }
if (args.shift() !== "to") { if (args.shift() !== "to") {
ritualFail(sin); ritualFail(sin);
throw `Illegal Invocation of a sin!`;
} }
if (args.shift() !== "summon") { if (args.shift() !== "summon") {
//TODO: we want to accept either "summon" or "bring forth" here but i cbf rn
ritualFail(sin); ritualFail(sin);
throw `Illegal Invocation of a sin!`;
} }
if (args.shift() !== "the") { if (args.shift() !== "the") {
ritualFail(sin); ritualFail(sin);
throw `Illegal Invocation of a sin!`;
} }
const adjective = args.shift(); const adjective = args.shift();
if (adjective !== "imposing" && adjective !== "foreboding") { if (adjective !== "imposing" && adjective !== "foreboding") {
//TODO: sin-specific adjectives //TODO: sin-specific adjectives
ritualFail(sin); ritualFail(sin);
throw `Illegal Invocation of a sin!`;
} }
const descriptor = args.shift(); const descriptor = args.shift();
if (descriptor !== "object" && descriptor !== "element") { if (descriptor !== "object" && descriptor !== "element") {
//TODO: typecheck this shit //TODO: typecheck this shit
ritualFail(sin); ritualFail(sin);
throw `Illegal Invocation of a sin!`;
} }
if (args.shift() !== "with" || args.shift() !== "a") { if (args.shift() !== "with" || args.shift() !== "a") {
ritualFail(sin); ritualFail(sin);
throw `Illegal Invocation of a sin!`;
} }
const filter = args.shift(); const filter = args.shift();
if (filter !== "display" && filter !== "property") { if (filter !== "display" && filter !== "property") {
ritualFail(sin); ritualFail(sin);
throw `Illegal Invocation of a sin!`;
} }
if (args.shift() !== "of" || args.shift() !== "name") { if (args.shift() !== "of" || args.shift() !== "name") {
ritualFail(sin); ritualFail(sin);
throw `Illegal Invocation of a sin!`;
} }
//TODO: HOW THE FUCK ARE WE SUPPOSED TO DO MULTIPLE PROPS? //TODO: HOW THE FUCK ARE WE SUPPOSED TO DO MULTIPLE PROPS?
//@ts-expect-error 2532 const prop = args.shift()?.slice(0, -1);
const prop = args.shift().slice(0, -1);
switch (filter) { switch (filter) {
case "display": case "display":
return webpack.findByDisplayName(prop); return webpack.findByDisplayName(prop);
break;
case "property": case "property":
return webpack.findByProps(prop); return webpack.findByProps(prop);
break;
default: default:
// the only way you can get here is with cosmic rays or divine intervention // the only way you can get here is with cosmic rays or divine intervention
ritualFail(sin); ritualFail(sin);

@ -1,57 +0,0 @@
import { React, nests, nestsReact } from "../../common";
import { toggle } from "../../plugin";
import webpack from "../../webpack";
const Checkbox = webpack.findByDisplayName("Checkbox");
interface HummusUI extends React.Component {
state: { tg: number }; //we love jank!
}
class HummusUI extends React.Component {
constructor(props: any) {
super(props);
this.state = {
tg: 0
};
}
render() {
const extNest = demon.summon("internal/nest");
return (
<div className="control-group demon-settings-card-header">
<label className="demon-settings-header-size30">Plugins</label>
{Object.keys(extNest.ghost.plugins).map((k) => {
return (
<div className="demon-settings-card-base">
<span>
<Checkbox
className={`demon-stub-plugin-checkbox-${k}`}
checked={extNest.ghost.plugins[k].enabled}
onChange={async () => {
toggle(k);
const ele =
document.getElementsByClassName(
`demon-stub-plugin-checkbox-${k}`
)[0] as HTMLInputElement;
//ele.value = extNest.ghost.pluginsStatus[k].running
if (!extNest.ghost.plugins[k].enabled) {
ele.value = "on";
} else {
ele.value = "off";
}
this.setState({ tg: !this.state.tg });
}}
>
{k}
</Checkbox>
</span>
</div>
);
})}
</div>
);
}
}
export default HummusUI;

@ -1,7 +1,6 @@
import webpack from "../../webpack"; import webpack from "../../webpack";
import { after } from "../../patcher"; import { after } from "../../patcher";
import plugins from "./plugins"; import plugins from "./plugins";
import hummus from "./hummus";
import css from "../../css"; import css from "../../css";
import { React } from "../../common"; import { React } from "../../common";
@ -72,38 +71,10 @@ function init() {
"font-size": "30px", "font-size": "30px",
"line-height": "34px" "line-height": "34px"
}); });
if (!!window.webpackChunkdiscord_app) { after(SettingsView.prototype, "getPredicateSections", (args, sections) => {
after( sections.unshift(...pluginSettings);
SettingsView.prototype, return sections;
"getPredicateSections", });
(args, sections) => {
sections.unshift(...pluginSettings);
return sections;
}
);
} else {
//I AM SO SORRY
const UserSettingsModal = webpack.findByProps(
"getUserSettingsModalSections"
);
const TabBar = webpack.findByProps("TabBarItem");
after("render", UserSettingsModal.default.prototype, (args, ret) => {
ret.props.children[0].props.children.props.children[1].push(
React.createElement(
TabBar.TabBarItem,
{ key: "demoncord" },
"Plugins"
)
);
if (
ret.props.children[0].props.children.props.selectedItem ===
"demoncord"
) {
ret.props.children[1].props.children[0].props.children =
React.createElement(hummus, {}, "");
}
});
}
} }
function add(name: string, ele: () => JSX.Element) { function add(name: string, ele: () => JSX.Element) {

@ -49,7 +49,7 @@ const warn = makeLogger(console.warn);
const error = makeLogger(console.error); const error = makeLogger(console.error);
const trace = makeLogger(console.trace); const trace = makeLogger(console.trace);
const debug = makeLogger((...args) => { const debug = makeLogger((...args) => {
/*#if _DEBUG /*#if _DEBUG
console.log(...args) console.log(...args)
//#endif */ //#endif */
}); });

@ -4,7 +4,7 @@ export function leak(mb: number): void {
if (!window.beelzejuice) { if (!window.beelzejuice) {
window.beelzejuice = []; //weird fanfic reference; i've seen this name used multiple times for alcoholic beverages window.beelzejuice = []; //weird fanfic reference; i've seen this name used multiple times for alcoholic beverages
} }
const id = Math.random().toString(36).slice(2); // const id = Math.random().toString(36).slice(2);
window.beelzejuice.push( window.beelzejuice.push(
new Uint8Array(Math.floor(mb * 1024 * 1024)).fill(666) new Uint8Array(Math.floor(mb * 1024 * 1024)).fill(666)
); );

@ -9,7 +9,7 @@ const ConfirmModal = findByDisplayName("ConfirmModal");
const Markdown = findByDisplayNameAll("Markdown")[1]; const Markdown = findByDisplayNameAll("Markdown")[1];
function rawOpenConfirmModal( function rawOpenConfirmModal(
component: any, Component: any,
props: any, props: any,
insideProps: any, insideProps: any,
insideContent: any insideContent: any
@ -30,14 +30,17 @@ function rawOpenConfirmModal(
<ConfirmModal <ConfirmModal
transitionState={e.transitionState} transitionState={e.transitionState}
onClose={() => (confirmed = false)} onClose={() => (confirmed = false)}
//@ts-ignore onCancel={() => {
onCancel={() => (confirmed = false & e.onClose())} confirmed = false;
//@ts-ignore e.onClose();
onConfirm={() => (confirmed = true & e.onClose())} }}
onConfirm={() => {
confirmed = true;
e.onClose();
}}
{...props} {...props}
> >
{/* @ts-ignore */} <Component {...insideProps}>{insideContent}</Component>
<component {...insideProps}>{insideContent}</component>
</ConfirmModal> </ConfirmModal>
); );
}); });

@ -8,34 +8,17 @@ interface Module {
let getModules: () => []; let getModules: () => [];
//check for hummus let modules: {
//TODO: nested conditional so we can *maybe* work with RN? c: [];
//TODO: account for different versions of webpackJsonp, ie ones that aren't a function (if/when hummus-like things come out) };
if (!window.webpackChunkdiscord_app) { window.webpackChunkdiscord_app.push([
let modules: { [Math.random().toString(36)],
c: []; {},
} = window.webpackJsonp( (e: { c: [] }) => {
[], modules = e;
[ }
(mod, _exports, req) => { ]);
mod.exports = req; getModules = () => modules.c;
}
]
);
getModules = () => modules.c;
} else {
let modules: {
c: [];
};
window.webpackChunkdiscord_app.push([
[Math.random().toString(36)],
{},
(e: { c: [] }) => {
modules = e;
}
]);
getModules = () => modules.c;
}
function filter(filter: Filter, moduleList: Module[]) { function filter(filter: Filter, moduleList: Module[]) {
let modules = []; let modules = [];

@ -55,8 +55,4 @@ window.demon = {
}; };
plugins.init(); plugins.init();
settings.init(); settings.init();
/*//#if _ANALYTICS
import analytics from "./api/analytics"
analytics.init()
//#endif*/
Loading…
Cancel
Save