add endpwn object during preload

This commit is contained in:
Astra 2018-05-08 20:59:52 -04:00
parent 28716d0347
commit 0370baa4c5
1 changed files with 29 additions and 28 deletions

View File

@ -15,7 +15,7 @@
*/
function __epprint(str) {
console.log(`%c[EndPwn]%c ` + str, 'font-weight:bold;color:#0cc', '');
console.log(`%c[EndPwn3]%c ` + str, 'font-weight:bold;color:#0cc', '');
}
exports = {
@ -32,7 +32,7 @@ exports = {
function fetchGoodies() {
// fetch goodies.json
__epprint('fetching endpwn cutomizer data from server...');
__epprint('fetching EndPwn Cutomizer data from server...');
fetch('https://endpwn.cathoderay.tube/goodies.json?_=' + Date.now())
.then(x => x.json())
.then(r => window.__goodies = r);
@ -42,6 +42,33 @@ exports = {
fetchGoodies();
setInterval(fetchGoodies, 1800000);
window.endpwn = {
__eval: e => eval(e),
uninstall: function () {
$api.ui.showDialog({
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',
onConfirm: () => {
var data = $api.data;
$api.settings.set('WEBAPP_ENDPOINT');
$api.settings.set('WEBAPP_PATH');
reload();
},
onCancel: () => console.log('<3')
});
}
};
// early init payload
document.addEventListener('ep-prepared', () => {
@ -101,32 +128,6 @@ exports = {
start: function () {
window.reload = () => { app.relaunch(); app.exit(); };
window.endpwn = {
__eval: e => eval(e),
uninstall: function () {
$api.ui.showDialog({
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',
onConfirm: () => {
var data = $api.data;
$api.settings.set('WEBAPP_ENDPOINT');
$api.settings.set('WEBAPP_PATH');
reload();
},
onCancel: () => console.log('<3')
});
}
};
// disable analytics
__epprint('disabling analytics...');