diff --git a/src/bootstrap.js b/src/bootstrap.js index 588e5e9..0f130c7 100644 --- a/src/bootstrap.js +++ b/src/bootstrap.js @@ -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); } -}; \ No newline at end of file +}; diff --git a/src/noTrack.js b/src/noTrack.js new file mode 100644 index 0000000..003c1a2 --- /dev/null +++ b/src/noTrack.js @@ -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({}); +}); \ No newline at end of file