mirror of
				https://github.com/notion-enhancer/notion-enhancer.git
				synced 2025-10-31 06:08:09 +11:00 
			
		
		
		
	fix: remove csp headers in notion desktop
This commit is contained in:
		
							parent
							
								
									d459455f3d
								
							
						
					
					
						commit
						7fe9bb2543
					
				| @ -1,5 +1,5 @@ | |||||||
| # notion-enhancer/desktop | # notion-enhancer/desktop | ||||||
| 
 | 
 | ||||||
| an enhancer/customiser for the all-in-one productivity workspace notion.so (app) | Customise the all-in-one productivity workspace Notion. | ||||||
| 
 | 
 | ||||||
| [read the docs online](https://notion-enhancer.github.io/) | [read the docs online](https://notion-enhancer.github.io/) | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ | |||||||
|   "name": "notion-enhancer", |   "name": "notion-enhancer", | ||||||
|   "version": "0.11.1", |   "version": "0.11.1", | ||||||
|   "author": "dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)", |   "author": "dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)", | ||||||
|   "description": "An enhancer/customiser for the all-in-one productivity workspace Notion", |   "description": "Customise the all-in-one productivity workspace Notion.", | ||||||
|   "homepage": "https://notion-enhancer.github.io", |   "homepage": "https://notion-enhancer.github.io", | ||||||
|   "repository": "github:notion-enhancer/desktop", |   "repository": "github:notion-enhancer/desktop", | ||||||
|   "bugs": "https://github.com/notion-enhancer/desktop/issues", |   "bugs": "https://github.com/notion-enhancer/desktop/issues", | ||||||
|  | |||||||
| @ -36,6 +36,11 @@ const patches = { | |||||||
|         (content = replaceIfNotFound( |         (content = replaceIfNotFound( | ||||||
|           { string: content, mode: "prepend" }, |           { string: content, mode: "prepend" }, | ||||||
|           ...args |           ...args | ||||||
|  |         )), | ||||||
|  |       append = (...args) => | ||||||
|  |         (content = replaceIfNotFound( | ||||||
|  |           { string: content, mode: "append" }, | ||||||
|  |           ...args | ||||||
|         )); |         )); | ||||||
| 
 | 
 | ||||||
|     // https://github.com/notion-enhancer/notion-enhancer/issues/160:
 |     // https://github.com/notion-enhancer/notion-enhancer/issues/160:
 | ||||||
| @ -53,12 +58,17 @@ const patches = { | |||||||
|     // bypass webRequest filter to load enhancer menu
 |     // bypass webRequest filter to load enhancer menu
 | ||||||
|     replace(/(\w)\.top!==\w\?(\w)\(\{cancel:!0\}\)/, "$1.top!==$1?$2({})"); |     replace(/(\w)\.top!==\w\?(\w)\(\{cancel:!0\}\)/, "$1.top!==$1?$2({})"); | ||||||
| 
 | 
 | ||||||
|     // https://github.com/notion-enhancer/desktop/issues/291
 |     // serve enhancer sources over the notion:// protocol
 | ||||||
|     // bypass csp issues by intercepting the notion:// protocol
 |  | ||||||
|     const protocolHandler = /try\{const \w=await \w\.assetCache\.handleRequest\(\w\);/, |     const protocolHandler = /try\{const \w=await \w\.assetCache\.handleRequest\(\w\);/, | ||||||
|       protocolInterceptor = `{const n="notion://www.notion.so/__notion-enhancer/";if(e.url.startsWith(n))return require("electron").net.fetch(\`file://\${require("path").join(__dirname,"..","..","node_modules","notion-enhancer",e.url.slice(n.length))}\`)}`; |       protocolInterceptor = `{const n="notion://www.notion.so/__notion-enhancer/";if(e.url.startsWith(n))return require("electron").net.fetch(\`file://\${require("path").join(__dirname,"..","..","node_modules","notion-enhancer",e.url.slice(n.length))}\`)}`; | ||||||
|     prepend(protocolHandler, protocolInterceptor); |     prepend(protocolHandler, protocolInterceptor); | ||||||
|      | 
 | ||||||
|  |     // disable csp entirely. risky? yes. necessary? also yes.
 | ||||||
|  |     // potentially could extend default policy instead someday.
 | ||||||
|  |     const headerHandler = /\.onHeadersReceived\(\(\((\w),\w\)=>{/, | ||||||
|  |       cspDisabler = `{const responseHeaders=$1.responseHeaders;if(responseHeaders){delete responseHeaders["content-security-policy"];return t({responseHeaders})}}` | ||||||
|  |     append(headerHandler, cspDisabler); | ||||||
|  | 
 | ||||||
|     // expose the app's config + cache + preferences to the global namespace
 |     // expose the app's config + cache + preferences to the global namespace
 | ||||||
|     // e.g. to enable development mode or check if keep in background is enabled
 |     // e.g. to enable development mode or check if keep in background is enabled
 | ||||||
|     prepend(/\w\.exports=JSON\.parse\('\{"env":"production"/, "globalThis.__notionConfig="); |     prepend(/\w\.exports=JSON\.parse\('\{"env":"production"/, "globalThis.__notionConfig="); | ||||||
|  | |||||||
| @ -2,7 +2,7 @@ | |||||||
|   "name": "notion-enhancer", |   "name": "notion-enhancer", | ||||||
|   "version": "0.11.1", |   "version": "0.11.1", | ||||||
|   "id": "0f0bf8b6-eae6-4273-b307-8fc43f2ee082", |   "id": "0f0bf8b6-eae6-4273-b307-8fc43f2ee082", | ||||||
|   "description": "an enhancer/customiser for the all-in-one productivity workspace notion.so", |   "description": "Customise the all-in-one productivity workspace Notion.", | ||||||
|   "tags": ["core"], |   "tags": ["core"], | ||||||
|   "authors": [ |   "authors": [ | ||||||
|     { |     { | ||||||
| @ -73,7 +73,7 @@ | |||||||
|       "key": "developerMode", |       "key": "developerMode", | ||||||
|       "description": "Activates built-in debugging tools accessible through the application menu.", |       "description": "Activates built-in debugging tools accessible through the application menu.", | ||||||
|       "platforms": ["linux", "win32", "darwin"], |       "platforms": ["linux", "win32", "darwin"], | ||||||
|       "value": true |       "value": false | ||||||
|     } |     } | ||||||
|   ], |   ], | ||||||
|   "clientStyles": ["variables.css", "../vendor/@unocss-preflight-tailwind.css"], |   "clientStyles": ["variables.css", "../vendor/@unocss-preflight-tailwind.css"], | ||||||
|  | |||||||
| @ -3,7 +3,7 @@ | |||||||
|   "name": "notion-enhancer", |   "name": "notion-enhancer", | ||||||
|   "version": "0.11.1", |   "version": "0.11.1", | ||||||
|   "author": "dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)", |   "author": "dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)", | ||||||
|   "description": "An enhancer/customiser for the all-in-one productivity workspace Notion", |   "description": "Customise the all-in-one productivity workspace Notion.", | ||||||
|   "homepage_url": "https://notion-enhancer.github.io", |   "homepage_url": "https://notion-enhancer.github.io", | ||||||
|   "content_scripts": [{ "matches": ["*://*.notion.so/*"], "js": ["/init.js"] }], |   "content_scripts": [{ "matches": ["*://*.notion.so/*"], "js": ["/init.js"] }], | ||||||
|   "background": { "service_worker": "/worker.js" }, |   "background": { "service_worker": "/worker.js" }, | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user