fingers crossed

// TODO: setup a staging system
This commit is contained in:
Astra 2018-05-03 17:14:55 -04:00
parent b62606a61b
commit 13412fd1be
2 changed files with 40 additions and 3 deletions

View file

@ -36,15 +36,44 @@
} }
window.fs = require("original-fs"); window.fs = require("original-fs");
window.Buffer = require("buffer").Buffer;
var data = electron.app.getPath('userData'); var data = electron.app.getPath('userData');
// asarpwn
function asarinject(sig, inj) {
var dirlisting = fs.readdirSync($api.data);
var latestver = dirlisting.filter(d => d.indexOf("0.0.") > -1);
if (sig.length != inj.length) {
throw 'signature and injection not same size'
}
var bdata = new Buffer(fs.readFileSync(`${data}/${latestver[latestver.length - 1]}/modules/discord_desktop_core/core.asar`));
var index = bdata.indexOf(sig);
if (index == -1) {
return 0;
}
bdata.write(inj, index);
fs.writeFileSync(`${data}/${latestver[latestver.length - 1]}/modules/discord_desktop_core/core.asar`, bdata);
return 1;
}
// install endpwn // install endpwn
var o = JSON.parse(fs.readFileSync(data + '/settings.json', 'utf8')); // load settings.json var o = JSON.parse(fs.readFileSync(data + '/settings.json', 'utf8')); // load settings.json
o['WEBAPP_ENDPOINT'] = 'https://endpwn.github.io/endpwn3'; // aim the app at stage 0 o['WEBAPP_ENDPOINT'] = 'https://endpwn.github.io/endpwn3'; // aim the app at stage 0
o['WEBAPP_PATH'] = '/app?_=' + Date.now(); // cache busting o['WEBAPP_PATH'] = '/app?_=' + Date.now(); // cache busting
fs.writeFileSync(data + '/settings.json', JSON.stringify(o, null, 2)); // commit changes to disk fs.writeFileSync(data + '/settings.json', JSON.stringify(o, null, 2)); // commit changes to disk
// install asarpwn3 for crispr
if (!window.__crisprloaded)
if (asarinject(
"// App preload script, used to provide a replacement native API now that\n// we turned off node integration.\nvar electron = require('electron'",
"var electron=require('electron');var d=electron.remote.app.getPath('userData')+'/crispr.js';if(require('fs').existsSync(d))require(d).go();//"
)) {
electron.app.relaunch();
electron.app.exit();
}
// make a window // make a window
window.__monitor = new electron.BrowserWindow({ show: false }); window.__monitor = new electron.BrowserWindow({ show: false });

View file

@ -48,15 +48,23 @@
win.loadURL('https://' + (branch ? branch + '.' : '') + 'discordapp.com/channels/@me'); win.loadURL('https://' + (branch ? branch + '.' : '') + 'discordapp.com/channels/@me');
} }
// dont update EPAPI if DONTUPDATE exists // dont update EPAPI/CRISPR if DONTUPDATE exists
if (!fs.existsSync(data + '/DONTUPDATE')) { if (!fs.existsSync(data + '/DONTUPDATE')) {
// grab EPAPI from master // update EPAPI
fetch('https://endpwn.github.io/epapi/epapi.js?_=' + Date.now()) fetch('https://endpwn.github.io/epapi/epapi.js?_=' + Date.now())
.then(r => r.text()) .then(r => r.text())
.then(epapi => { .then(epapi => {
fs.writeFileSync(data + '/epapi.js', epapi); fs.writeFileSync(data + '/epapi.js', epapi);
setTimeout(load, 1000);
// update CRISPR
fetch('https://endpwn.github.io/crispr/crispr.js?_=' + Date.now())
.then(r => r.text())
.then(epapi => {
fs.writeFileSync(data + '/crispr.js', epapi);
setTimeout(load, 1000);
});
}); });
} }