[NoTrack] Disable Sentry in main window inject instead of JS intercepting
This commit is contained in:
		
							parent
							
								
									c3b020f0f1
								
							
						
					
					
						commit
						0018c52257
					
				
					 2 changed files with 10 additions and 19 deletions
				
			
		
							
								
								
									
										22
									
								
								src/bootstrap.js
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										22
									
								
								src/bootstrap.js
									
										
									
									
										vendored
									
									
								
							|  | @ -41,7 +41,8 @@ const startCore = () => { | |||
|       const [ channel, hash ] = oaVersion.split('-'); // Split via -
 | ||||
| 
 | ||||
|       bw.webContents.executeJavaScript(readFileSync(join(__dirname, 'mainWindow.js'), 'utf8') | ||||
|         .replaceAll('<hash>', hash || 'custom')); | ||||
|         .replaceAll('<hash>', hash || 'custom')) | ||||
|         .replaceAll('<notrack>', oaConfig.noTrack); | ||||
| 
 | ||||
|       if (oaConfig.js) bw.webContents.executeJavaScript(oaConfig.js); | ||||
|     }); | ||||
|  | @ -73,24 +74,7 @@ const startCore = () => { | |||
| }; | ||||
| 
 | ||||
| const startUpdate = () => { | ||||
|   if (oaConfig.noTrack !== false) { | ||||
|     const bl = { cancel: true }; // Standard block callback response
 | ||||
| 
 | ||||
|     let sentry; | ||||
|     session.defaultSession.webRequest.onBeforeRequest({ | ||||
|       urls: [ | ||||
|         'https://*.discord.com/assets/*.js', | ||||
|         'https://*/api/*/science' | ||||
|       ] | ||||
|     }, async ({ url }, cb) => { | ||||
|       if (url.endsWith('/science')) return cb(bl); | ||||
| 
 | ||||
|       if (!sentry && (await new Promise((res) => get(url, (e, r, b) => res(b)))).includes('RecipeWebview')) sentry = url; | ||||
|       if (sentry === url) return cb(bl); | ||||
| 
 | ||||
|       cb({}); | ||||
|     }); | ||||
|   } | ||||
|   if (oaConfig.noTrack !== false) session.defaultSession.webRequest.onBeforeRequest({ urls: [ 'https://*/api/v9/science' ] }, async (e, cb) => cb({ cancel: true })); | ||||
| 
 | ||||
|   const startMin = process.argv?.includes?.('--start-minimized'); | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,3 +1,10 @@ | |||
| if ('<notrack>' === 'true') { // Disable sentry
 | ||||
|   try { | ||||
|     window.__SENTRY__.hub.getClient().getOptions().enabled = false; | ||||
|     Object.keys(console).forEach(x => console[x] = console[x].__sentry_original__ ?? console[x]); | ||||
|   } catch { } | ||||
| } | ||||
| 
 | ||||
| let lastBgPrimary = ''; | ||||
| const themesync = async () => { | ||||
|   const getVar = (name, el = document.body) => el && (getComputedStyle(el).getPropertyValue(name) || getVar(name, el.parentElement))?.trim(); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue