mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-11 15:59:03 +00:00
Fix white screen issue on startup
This commit is contained in:
parent
d5e0810915
commit
67518d6be9
9
scripts/patch-desktop-app.mjs
Executable file → Normal file
9
scripts/patch-desktop-app.mjs
Executable file → Normal file
@ -47,7 +47,7 @@ const patches = {
|
|||||||
// enable the notion:// protocol, windows-style tab layouts, and
|
// enable the notion:// protocol, windows-style tab layouts, and
|
||||||
// quitting the app when the last window is closed on linux
|
// quitting the app when the last window is closed on linux
|
||||||
const isWindows =
|
const isWindows =
|
||||||
/(?:"win32"===process\.platform(?:(?=,isFullscreen)|(?=&&\w\.BrowserWindow)|(?=&&\(\w\.app\.requestSingleInstanceLock)))/g,
|
/(?:"win32"===process\.platform(?:(?=,isFullscreen)|(?=&&\w\.BrowserWindow)|(?=&&\(\w\.app\.requestSingleInstanceLock))))/g,
|
||||||
isWindowsOrLinux = '["win32","linux"].includes(process.platform)';
|
isWindowsOrLinux = '["win32","linux"].includes(process.platform)';
|
||||||
replace(isWindows, isWindowsOrLinux);
|
replace(isWindows, isWindowsOrLinux);
|
||||||
|
|
||||||
@ -63,11 +63,10 @@ const patches = {
|
|||||||
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.
|
// Modify CSP instead of disabling it entirely
|
||||||
// potentially could extend default policy instead someday.
|
|
||||||
const headerHandler = /\.onHeadersReceived\(\(\((\w),\w\)=>{/,
|
const headerHandler = /\.onHeadersReceived\(\(\((\w),\w\)=>{/,
|
||||||
cspDisabler = `{const responseHeaders=$1.responseHeaders;if(responseHeaders){delete responseHeaders["content-security-policy"];return t({responseHeaders})}}`
|
cspModifier = `{const responseHeaders=$1.responseHeaders;if(responseHeaders && responseHeaders["content-security-policy"]){responseHeaders["content-security-policy"] = responseHeaders["content-security-policy"][0].replace(/script-src/g, 'script-src notion: file:');return t({responseHeaders})}}`
|
||||||
append(headerHandler, cspDisabler);
|
append(headerHandler, cspModifier);
|
||||||
|
|
||||||
// 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
|
||||||
|
Loading…
Reference in New Issue
Block a user