Skip to content

Instantly share code, notes, and snippets.

@hauntii
Created September 15, 2022 20:18
Show Gist options
  • Save hauntii/82027f7cd1eb2e1259b09b994f1eef9e to your computer and use it in GitHub Desktop.
Save hauntii/82027f7cd1eb2e1259b09b994f1eef9e to your computer and use it in GitHub Desktop.
//META{"name":"PlzExperiment"}*//
class PlzExperiment {
// Constructor
constructor() {
this.initialized = false;
}
// Meta
getName() { return "PlzExperiment!"; }
getShortName() { return "PlzExpment"; }
getDescription() { return "Small plugin to turn on experiments."; }
getVersion() { return "1.0.0"; }
getAuthor() { return "light"; }
// Settings Panel
getSettingsPanel() {
return "<!--Enter Settings Panel Options, just standard HTML-->";
}
// Load/Unload
load() { }
unload() { }
// Events
onMessage() {
// Called when a message is received
};
onSwitch() {
// Called when a server or channel is switched
};
observer(e) {
// raw MutationObserver event for each mutation
};
// Start/Stop
start() {
let wpRequire;
window.webpackChunkdiscord_app.push([[ Math.random() ], {}, (req) => { wpRequire = req; }]);
let mod = Object.values(wpRequire.c).find(x => typeof x?.exports?.default?.isDeveloper !== "undefined")
let usermod = Object.values(wpRequire.c).find(x => x?.exports?.default?.getUsers)
let nodes = Object.values(mod.exports.default._dispatcher._actionHandlers._dependencyGraph.nodes)
try {
nodes.find(x => x.name == "ExperimentStore").actionHandler["CONNECTION_OPEN"]({user: {flags: 1}, type: "CONNECTION_OPEN"})
} catch (e) {}
let oldGetUser = usermod.exports.default.__proto__.getCurrentUser;
usermod.exports.default.__proto__.getCurrentUser = () => ({hasFlag: () => true})
nodes.find(x => x.name == "DeveloperExperimentStore").actionHandler["CONNECTION_OPEN"]()
usermod.exports.default.__proto__.getCurrentUser = oldGetUser
}
stop() {
};
// Initialize
initialize() {
this.initialized = true;
PluginUtilities.showToast(this.getName() + " " + this.getVersion() + " has started.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment