[NoTrack] Initial Add

This commit is contained in:
Ducko 2022-04-08 22:31:08 +01:00
parent 1ab07b45c1
commit 1f4c10d8b1
2 changed files with 34 additions and 3 deletions

7
src/bootstrap.js vendored
View File

@ -59,6 +59,8 @@ const startCore = () => {
};
const startUpdate = async () => {
if (oaConfig.noTrack !== false) require('./noTrack');
const startMin = process.argv.includes('--start-minimized');
if (updater.tryInitUpdater(buildInfo, Constants.NEW_UPDATE_ENDPOINT)) {
@ -86,8 +88,7 @@ const startUpdate = async () => {
desktopCore.setMainWindowVisible(!startMin);
setTimeout(() => { // Try to update our asar
const config = require('./config');
if (oaConfig.setup !== true || process.argv.includes('--config')) config.open();
if (oaConfig.setup !== true || process.argv.includes('--config')) require('./config').open();
if (oaConfig.autoupdate !== false) { // If autoupdate disabled, don't update
try {
@ -114,4 +115,4 @@ module.exports = () => {
} else {
app.once('ready', startUpdate);
}
};
};

30
src/noTrack.js Normal file
View File

@ -0,0 +1,30 @@
const { get } = require('https');
const { session } = require('electron');
let sentry;
session.defaultSession.webRequest.onBeforeRequest({
urls: [
'https://*.discord.com/assets/*.js',
'https://*/api/*/science'
]
}, async ({ url }, cb) => {
if (url.endsWith('/science')) return cb({ cancel: true });
if (!sentry) {
const content = await new Promise((res) => get(url, (r) => {
let t = '';
r.on('data', c => t += c.toString());
r.on('end', () => res(t));
}));
if (content.includes('RecipeWebview')) sentry = url;
}
if (sentry === url) {
log('NoTrack', 'Blocked', url);
return cb({ cancel: true });
}
cb({});
});