run prettier

someone remind me to setup a pre-commit hook for this
typescript
Drake 2 years ago
parent 91c93322b3
commit 377c71b97a

@ -5,5 +5,5 @@ import modals from "./utils/modals";
}) */
export default {
init: ()=>{}
}
init: () => {}
};

@ -1,58 +1,57 @@
function wackyPatch(parentObj, name, patches) {
if (typeof parentObj === "string") {
//assume parentObj and name are switched around (for backcompat/convienence)
const tmp = parentObj
parentObj = name
name = tmp
}
const injId = Symbol()
const before = patches["before"];
if (typeof parentObj === "string") {
//assume parentObj and name are switched around (for backcompat/convienence)
const tmp = parentObj;
parentObj = name;
name = tmp;
}
const injId = Symbol();
const before = patches["before"];
const instead = patches["instead"];
const after = patches["after"];
const after = patches["after"];
const handler = {
apply: (target, thisArg, [ctx, args]) => {
if (before !== undefined) before.apply(ctx, [args]);
const res = (patches["instead"] !== undefined) ? instead.apply(ctx, [args, target.bind(ctx)]) : target.apply(ctx, args)
if (after === undefined) return res
const res =
patches["instead"] !== undefined
? instead.apply(ctx, [args, target.bind(ctx)])
: target.apply(ctx, args);
if (after === undefined) return res;
return after.apply(ctx, [args, res]);
}
};
const prox = new Proxy(parentObj[name], handler);
const orig = parentObj[name];
parentObj[name] = function() {
parentObj[name] = function () {
return prox(this, arguments);
};
const unpatch = () => {
parentObj[name] = orig;
}
};
parentObj[injId] = {
name: name,
orig: orig,
name: name,
orig: orig,
unpatch: unpatch
};
return unpatch;
}
function before(parentObj, name, func) {
return wackyPatch(parentObj, name, {before: func})
return wackyPatch(parentObj, name, { before: func });
}
function instead(parentObj, name, func) {
return wackyPatch(parentObj, name, {instead: func})
return wackyPatch(parentObj, name, { instead: func });
}
function after(parentObj, name, func) {
return wackyPatch(parentObj, name, {after: func})
return wackyPatch(parentObj, name, { after: func });
}
export {
instead,
before,
after
}
export { instead, before, after };
export default {
instead,
before,
after
}
instead,
before,
after
};

@ -9,75 +9,77 @@
}*/
import { idb, nests } from "./common";
import logger from "./utils/logger"
import logger from "./utils/logger";
const ctxNest = nests.make(); //Plugin context nest (I would create this in index, but it's not a good idea to expose that)
let pluginNest;
const pluginEval = (iife) => (0,eval)(iife) //defined as a separate function in case we want to do more things on plugin eval later
const pluginEval = (iife) => (0, eval)(iife); //defined as a separate function in case we want to do more things on plugin eval later
async function savePlugin(eve, { path, value }) {
logger.debug(["Plugins"], `Got ${eve} event for plugin manager's nest with path ${path} and val ${value}`)
logger.debug(
["Plugins"],
`Got ${eve} event for plugin manager's nest with path ${path} and val ${value}`
);
await idb.set("demon", {
plugins: pluginNest.ghost.plugins
})
});
}
async function init() {
pluginNest = demon.summon("internal/nest") //we don't have access to the global yet outside of the function
pluginNest = demon.summon("internal/nest"); //we don't have access to the global yet outside of the function
if (!(await idb.get("demon"))) {
await idb.set("demon", {
plugins: {} //we need to pre-create this i guess?
})
});
}
pluginNest.store.plugins = (await idb.get("demon")).plugins //we do this before we setup our hook to avoid any potential conflicts
pluginNest.on(nests.Events.SET, savePlugin)
pluginNest.on(nests.Events.DELETE, savePlugin)
pluginNest.store.plugins = (await idb.get("demon")).plugins; //we do this before we setup our hook to avoid any potential conflicts
pluginNest.on(nests.Events.SET, savePlugin);
pluginNest.on(nests.Events.DELETE, savePlugin);
Object.keys(pluginNest.ghost.plugins).forEach((ele) => {
if (pluginNest.ghost.plugins[ele].enabled) {
const exports = pluginEval(pluginNest.ghost.plugins[ele].iife)
const ctx = exports.onStart() //actually starts plugin
ctxNest.store[ele] = ctx
pluginNest.store.plugins[ele].enabled = true //for clarity
const exports = pluginEval(pluginNest.ghost.plugins[ele].iife);
const ctx = exports.onStart(); //actually starts plugin
ctxNest.store[ele] = ctx;
pluginNest.store.plugins[ele].enabled = true; //for clarity
} else {
pluginNest.store.plugins[ele].enabled = false //for clarity
pluginNest.store.plugins[ele].enabled = false; //for clarity
}
})
});
}
function add(iife) {
const exports = pluginEval(iife)
logger.debug(["Plugins"], `Adding ${exports.meta.name}`)
const exports = pluginEval(iife);
logger.debug(["Plugins"], `Adding ${exports.meta.name}`);
pluginNest.store.plugins[exports.meta.name] = {
iife,
enabled: false,
desc: exports.meta.desc
}
};
}
function del(name) {
if (!!pluginNest.ghost.plugins[name]) {
logger.debug(["Plugins"], `Removing ${name}`)
delete pluginNest.store.plugins[name]
logger.debug(["Plugins"], `Removing ${name}`);
delete pluginNest.store.plugins[name];
} else {
throw new Error("Can't delete plugin that doesn't exist. lol")
throw new Error("Can't delete plugin that doesn't exist. lol");
}
}
function toggle(name) {
if (!!pluginNest.ghost.plugins[name]) {
if (pluginNest.ghost.plugins[name].enabled) {
logger.debug(["Plugins"], `Disabling ${name}`)
const exports = pluginEval(pluginNest.ghost.plugins[name].iife)
exports.onStop(ctxNest.store[name])
pluginNest.store.plugins[name].enabled = false
logger.debug(["Plugins"], `Disabling ${name}`);
const exports = pluginEval(pluginNest.ghost.plugins[name].iife);
exports.onStop(ctxNest.store[name]);
pluginNest.store.plugins[name].enabled = false;
} else {
logger.debug(["Plugins"], `Enabling ${name}`)
const exports = pluginEval(pluginNest.ghost.plugins[name].iife)
const ctx = exports.onStart()
ctxNest.store[name] = ctx
pluginNest.store.plugins[name].enabled = true
logger.debug(["Plugins"], `Enabling ${name}`);
const exports = pluginEval(pluginNest.ghost.plugins[name].iife);
const ctx = exports.onStart();
ctxNest.store[name] = ctx;
pluginNest.store.plugins[name].enabled = true;
}
}
}

@ -12,9 +12,7 @@ const Switch = webpack.findByDisplayName("Switch");
export default (props) => {
nestsReact.useNest(props.nest);
if (
!props.nest.ghost.plugins[props.name]
) {
if (!props.nest.ghost.plugins[props.name]) {
return null; //you wouldn't think i'd have to do this but
}
return (

@ -4,7 +4,7 @@
//#endif
import { React, nests, nestsReact } from "../../common";
import { add } from "../../plugin"
import { add } from "../../plugin";
import webpack from "../../webpack";
import PlugCard from "./plugincard.jsx";
@ -16,7 +16,7 @@ const Button = webpack.findByProps("BorderColors", "Colors");
export default () => {
const extNest = demon.summon("internal/nest");
const [input, setInput] = React.useState("")
const [input, setInput] = React.useState("");
nestsReact.useNest(extNest);
return (
<>
@ -30,9 +30,11 @@ export default () => {
onChange={setInput}
onKeyDown={async (eve) => {
if (eve.key === "Enter") {
const text = await (await fetch("$_CORS_URL" + input)).text()
const text = await (
await fetch("$_CORS_URL" + input)
).text();
add(text);
setInput("")
setInput("");
}
}}
/>

@ -20,7 +20,7 @@ let pluginSettings = [
{
section: "DIVIDER"
}
]
];
function init() {
css.createClass("demon-settings-url", {
@ -77,9 +77,7 @@ function init() {
SettingsView.prototype,
"getPredicateSections",
(args, sections) => {
sections.unshift(
...pluginSettings
);
sections.unshift(...pluginSettings);
return sections;
}
);
@ -109,14 +107,15 @@ function init() {
}
function addPluginEntry(name, ele) {
const idx = pluginSettings.push({
section: "demoncord-plugins",
label: "name",
element: ele
}) - 1
const idx =
pluginSettings.push({
section: "demoncord-plugins",
label: "name",
element: ele
}) - 1;
return () => {
delete pluginSettings[idx]
}
delete pluginSettings[idx];
};
}
export default { init, addPluginEntry };

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

@ -1,77 +1,75 @@
import webpack from "../webpack"
import { React } from "../common"
import webpack from "../webpack";
import { React } from "../common";
const { findByProps, findByDisplayName, findByDisplayNameAll } = webpack
const { findByProps, findByDisplayName, findByDisplayNameAll } = webpack;
const { openModal } = findByProps("openModalLazy")
const Colors = findByProps("button", "colorRed")
const ConfirmModal = findByDisplayName("ConfirmModal")
const Markdown = findByDisplayNameAll("Markdown")[1]
const { openModal } = findByProps("openModalLazy");
const Colors = findByProps("button", "colorRed");
const ConfirmModal = findByDisplayName("ConfirmModal");
const Markdown = findByDisplayNameAll("Markdown")[1];
function rawOpenConfirmModal(component, props, insideProps, insideContent) {
if (insideProps === undefined) {
insideProps = {}
}
if (insideContent === undefined) {
insideContent = ""
}
let confirmed;
openModal((e) => {
if (e.transitionState === 3) {
return false //TODO: the fuck does this do?
}
if (insideProps === undefined) {
insideProps = {};
}
if (insideContent === undefined) {
insideContent = "";
}
let confirmed;
openModal((e) => {
if (e.transitionState === 3) {
return false; //TODO: the fuck does this do?
}
return (
<ConfirmModal
transitionState={e.transitionState}
onClose = {() => confirmed = false}
onCancel = {() => confirmed = false & e.onClose()}
onConfirm = {() => confirmed = true & e.onClose()}
{...props}
>
<component {...insideProps}>{insideContent}</component>
</ConfirmModal>
)
})
while (confirmed === undefined) {
}
return confirmed
return (
<ConfirmModal
transitionState={e.transitionState}
onClose={() => (confirmed = false)}
onCancel={() => (confirmed = false & e.onClose())}
onConfirm={() => (confirmed = true & e.onClose())}
{...props}
>
<component {...insideProps}>{insideContent}</component>
</ConfirmModal>
);
});
while (confirmed === undefined) {}
return confirmed;
}
function openConfirmModal(content, type, opts) {
let buttonColor;
if (!!opts.color) {
buttonColor = opts.color
} else {
switch (type) {
case "danger":
buttonColor = Colors.colorRed
break
case "confirm":
buttonColor = Colors.colorGreen
break
default:
buttonColor = Colors.colorBrandNew
break
}
}
return rawOpenConfirmModal(
Markdown,
{
header: opts.header ?? "Default Modal Header",
confirmText: opts.confirmText ?? "Confirm",
cancelText: opts.cancelText ?? "Cancel",
confirmButtonColor: buttonColor
},
{
editable: false
},
content ?? "Default modal content"
)
let buttonColor;
if (!!opts.color) {
buttonColor = opts.color;
} else {
switch (type) {
case "danger":
buttonColor = Colors.colorRed;
break;
case "confirm":
buttonColor = Colors.colorGreen;
break;
default:
buttonColor = Colors.colorBrandNew;
break;
}
}
return rawOpenConfirmModal(
Markdown,
{
header: opts.header ?? "Default Modal Header",
confirmText: opts.confirmText ?? "Confirm",
cancelText: opts.cancelText ?? "Cancel",
confirmButtonColor: buttonColor
},
{
editable: false
},
content ?? "Default modal content"
);
}
export default {
rawOpenConfirmModal,
openConfirmModal
}
rawOpenConfirmModal,
openConfirmModal
};

@ -58,7 +58,7 @@ let webpack = {
return webpack.find((m) => m?.displayName === prop);
},
findByDisplayNameAll: (prop) => {
return webpack.findAll((m) => m?.displayName === prop)
return webpack.findAll((m) => m?.displayName === prop);
},
findByStrings: (...props) => {
return webpack.find((module) =>
@ -71,4 +71,4 @@ let webpack = {
}
};
export default webpack;
export default webpack;

@ -20,14 +20,16 @@ const demon = {
patcher,
stolas: {
monologue: () => {
const username = webpack.findByProps("getCurrentUser").getCurrentUser().username
const username = webpack
.findByProps("getCurrentUser")
.getCurrentUser().username;
return _.sample([
`${username}, you know that when I'm lonely, I become hungry. And when I become hungry, I want to choke on that red **** of yours... **** your ***** and lick all of your *****, before taking out your *****, and **** with more teeth until you're screaming ********** like a FUCKING baby--!`,
`Ohhh, ${username}! I'm so excited! I cannot wait to feel your slimy c**k inside of my ****. To ***** the— ...**** use while you and I and **** and jelly sandwiches all night...!`
]);
}
}
}
};
function isAllowed(mod) {
//TODO: actually implement permissions
@ -59,4 +61,4 @@ settings.init();
/*//#if _ANALYTICS
import analytics from "./api/analytics"
analytics.init()
//#endif*/
//#endif*/

Loading…
Cancel
Save