endpwn3.2-lambda/plugin/system.js

204 lines
9.9 KiB
JavaScript
Raw Normal View History

2018-06-13 22:25:08 +00:00
/*
EndPwn3 System (bootstrap)
Copyright 2018 EndPwn Project
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
DO NOT EDIT THIS FILE! Your bootstrap may overwrite changes to it, and you will lose your work!
EndPwn3 users: You can prevent this by creating a file in the same directory named DONTUPDATE
https://github.com/endpwn/
*/
var internal = {
2018-07-12 00:32:22 +00:00
print: function(str) {
console.log(`%c[EndPwn3]%c ` + str, "font-weight:bold;color:#0cc", "");
2018-06-13 22:25:08 +00:00
},
2018-07-12 00:32:22 +00:00
warn: function(str) {
console.warn(`%c[EndPwn3]%c ` + str, "font-weight:bold;color:#0cc", "");
2018-06-13 22:25:08 +00:00
}
2018-07-12 00:32:22 +00:00
};
2018-06-13 22:25:08 +00:00
2018-06-16 00:05:38 +00:00
exports = {
2018-06-15 23:50:37 +00:00
manifest: {
replacements: [
// changelog injection
/*{
signature: /key:"changeLog",get:function\(\){return (\w)}/g,
payload: 'key:"changeLog",get:function(){if(!$1.injected){$1.injected=1;$1.date=$1.date<=window.endpwn.changelog.date?window.endpwn.changelog.date:$1.date;$1.body=window.endpwn.changelog.body+"\\n\\n"+$1.body}return $1}'
},*/
// crash screen hijack
{
signature: /var (\w)=(\w)\("div",{},void 0,\w\("p",{},void 0,(\w)\.default\.Messages\.ERRORS_UNEXPECTED_CRASH\),\w\("p",{},void 0,\w\.default\.Messages\.ERRORS_ACTION_TO_TAKE\)\),(\w)=\w\((\w)\.default,{size:(\w)\.ButtonSizes\.LARGE,onClick:this\._handleSubmitReport},void 0,a\.default\.Messages\.ERRORS_RELOAD\);return o\(u\.default,{theme:this\.props.theme,title:a\.default\.Messages\.UNSUPPORTED_BROWSER_TITLE,/g,
payload: `var $1=$2("div",{},void 0,$2("p",{},void 0,"Something has gone very, very wrong, and Discord has crashed."),$2("p",{},void 0,"If this is the first time you've seen this error screen, reload and hope for the best. If this screen appears again, follow these steps:"),$2("p",{},void 0,"Try removing any new plugins and restarting again. If this solves the problem there may be a bug in a plugin or a conflict."),$2("p",{},void 0,"If problems continue, it's likely that there is a bug in EndPwn or Discord."),$2("p",{},void 0,"If you need help, join the EndPwn Discord server (https://discord.gg/wXdPNf2)"),$2("p",{},void 0,"Details may be available in the console (Ctrl+Shift+I), but at this level of crash we can't be certain.")),$4=$2("div",{},void 0,$2($5.default,{size:$6.ButtonSizes.LARGE,onClick:()=>window.electron.getCurrentWindow().reload()},void 0,"Reload"),$2($5.default,{size:$6.ButtonSizes.LARGE,onClick:()=>{window.$api.localStorage.set('safemode',1);window.electron.getCurrentWindow().reload()}},void 0,"Reload in safe mode"));return $2(u.default,{theme:this.props.theme,title:"Discord: Fatal Error",`
2018-06-16 00:05:38 +00:00
},
// experiments
{
signature: "window.GLOBAL_ENV.RELEASE_CHANNEL",
payload: "'staging'"
2018-06-15 23:50:37 +00:00
}
2018-07-12 00:32:22 +00:00
]
2018-06-15 23:50:37 +00:00
},
2018-06-13 22:25:08 +00:00
2018-07-12 00:32:22 +00:00
preload: function() {
window.reload = () => {
app.relaunch();
app.exit();
};
2018-06-15 23:50:37 +00:00
window.endpwn = {
// safemode
2018-07-12 00:32:22 +00:00
safemode: function() {
2018-06-15 23:50:37 +00:00
$api.ui.showDialog({
2018-07-12 00:32:22 +00:00
title: "EndPwn: safe mode",
body:
"This will restart your client in a state without plugin support.",
confirmText: "Yes",
cancelText: "No",
2018-06-13 22:25:08 +00:00
2018-06-15 23:50:37 +00:00
onConfirm: () => {
2018-07-12 00:32:22 +00:00
$api.localStorage.set("safemode", 1);
2018-06-15 23:50:37 +00:00
window.electron.getCurrentWindow().reload();
}
});
},
2018-06-13 22:25:08 +00:00
2018-06-15 23:50:37 +00:00
// uninstaller
2018-07-12 00:32:22 +00:00
uninstall: function() {
2018-06-15 23:50:37 +00:00
$api.ui.showDialog({
2018-07-12 00:32:22 +00:00
title: "EndPwn: confirm uninstallation",
body:
"Are you sure you want to remove EndPwn from your client? You can reinstall it at any time.",
confirmText: "Yes",
cancelText: "No",
2018-06-13 22:25:08 +00:00
2018-06-15 23:50:37 +00:00
onConfirm: () => {
var data = $api.data;
2018-06-13 22:25:08 +00:00
2018-07-12 00:32:22 +00:00
$api.settings.set("WEBAPP_ENDPOINT");
$api.settings.set("WEBAPP_PATH");
$api.settings.set("UPDATE_ENDPOINT");
2018-06-13 22:25:08 +00:00
2018-06-15 23:50:37 +00:00
reload();
}
});
},
2018-06-13 22:25:08 +00:00
2018-06-15 23:50:37 +00:00
// endpwn customizer
2018-07-12 00:32:22 +00:00
//customizer: krequire('customizer'),
2018-06-13 22:25:08 +00:00
2018-06-15 23:50:37 +00:00
// settings page stuff
2018-07-12 00:32:22 +00:00
settings: krequire("settings"),
2018-06-13 22:25:08 +00:00
2018-06-15 23:50:37 +00:00
// wrapper function for dispatch()
// intended to simplify using executeJavaScript() from other windows as a bad IPC method
// we do this since afaik we cant use electron.ipc in a useful way (maybe im wrong? if i am ill make this better later on lol)
2018-07-12 00:32:22 +00:00
pseudoipc: function(e) {
2018-06-15 23:50:37 +00:00
$api.events.dispatch({
2018-07-12 00:32:22 +00:00
type: "ENDPWN_PSEUDO_IPC",
2018-06-15 23:50:37 +00:00
data: e
});
},
2018-06-13 22:25:08 +00:00
2018-06-15 23:50:37 +00:00
__eval: e => eval(e)
};
2018-06-13 22:25:08 +00:00
2018-06-15 23:50:37 +00:00
// fetch the changelog
/*internal.print('retrieving changelog...');
fetch('https://dr1ft.xyz/ep/changelog.txt?_=' + Date.now()).then(r => r.text()).then(l => {
var data = l.split(';;');
window.endpwn.changelog = {
date: data[0],
body: data[1]
2018-06-13 22:25:08 +00:00
};
2018-06-15 23:50:37 +00:00
});*/
2018-06-13 22:25:08 +00:00
2018-06-15 23:50:37 +00:00
// early init payload
2018-07-12 00:32:22 +00:00
document.addEventListener("ep-prepared", () => {
2018-06-15 23:50:37 +00:00
// disable that obnoxious warning about not pasting shit in the console
2018-07-12 00:32:22 +00:00
internal.print("disabling self xss warning...");
$api.util.findFuncExports(
"consoleWarning"
).consoleWarning = e => {};
2018-06-13 22:25:08 +00:00
2018-06-15 23:50:37 +00:00
// fuck sentry
2018-07-12 00:32:22 +00:00
internal.print("fucking sentry...");
var sentry = wc.findCache("_originalConsoleMethods")[0].exports;
window.console = Object.assign(
window.console,
sentry._originalConsoleMethods
); // console
sentry._wrappedBuiltIns.forEach(x => (x[0][x[1]] = x[2])); // other stuff
sentry._breadcrumbEventHandler = () => () => {}; // break most event logging
sentry.captureBreadcrumb = () => {}; // disable breadcrumb logging
2018-06-15 23:50:37 +00:00
});
},
2018-06-13 22:25:08 +00:00
2018-07-12 00:32:22 +00:00
start: function() {
2018-06-15 23:50:37 +00:00
// disable analytics
2018-07-12 00:32:22 +00:00
internal.print("disabling analytics...");
$api.util.findFuncExports(
"AnalyticEventConfigs"
).default.track = () => {};
2018-06-13 22:25:08 +00:00
2018-06-15 23:50:37 +00:00
// enable experiments
2018-07-12 00:32:22 +00:00
internal.print("enabling experiments menu...");
$api.util
.findFuncExports("isDeveloper")
.__defineGetter__("isDeveloper", () => true);
2018-06-13 22:25:08 +00:00
2018-06-15 23:50:37 +00:00
// if we used start() in the other files, it would create a different instance -- we dont want that
endpwn.customizer.init();
endpwn.settings.init();
2018-06-13 22:25:08 +00:00
2018-06-15 23:50:37 +00:00
// check for epapi updates
2018-07-12 00:32:22 +00:00
if ($api.lite || !fs.existsSync($api.data + "/DONTUPDATE"))
(function() {
internal.print("checking for EPAPI updates...");
// fetch the latest build of epapi
fetch(
"https://lambda.cynfoxwell.cf/epapi/epapi.js?_=" +
Date.now()
)
.then(x => x.text())
.then(x => {
// check the version
if (kparse(x).version > $api.version) {
// if the version on the server is newer, pester the user
$api.ui.showDialog({
title: "EndPwn3: EPAPI Update Available",
body:
"An update to EPAPI has been released. It is recommended that you restart your client in order to gain access to new features and maintain compatibility.",
confirmText: "Restart Now",
cancelText: "Later",
// user pressed "Restart Now"
onConfirm: () => {
// refresh the page if we're running in a browser, reboot the app if we're running outside of lite mode
reload();
},
// they pressed "Later", for some reason
onCancel: () => {
// bother them again in 6 hrs (* 60 min * 60 sec * 1000 ms)
setTimeout(
arguments.callee,
6 * 60 * 60 * 1000
);
}
});
} else setTimeout(arguments.callee, 6 * 60 * 60 * 1000);
2018-06-13 22:25:08 +00:00
});
2018-07-12 00:32:22 +00:00
})();
2018-06-15 23:50:37 +00:00
}
2018-07-12 00:32:22 +00:00
};