Notion Fix

This commit is contained in:
Kamesuta 2020-12-05 16:44:28 +09:00
parent e1af50c149
commit 61bf01f5b3
2 changed files with 35 additions and 3 deletions

View File

@ -1177,13 +1177,35 @@ notion.contentWindow.addEventListener('DOMContentLoaded', event => {
style.innerHTML += '.notion-topbar { display: none !important; }'
style.innerHTML += '.notion-page-content { align-items: start !important; padding-left: 0 !important; padding-right: 0 !important; padding-bottom: 0 !important; }'
style.innerHTML += '.notion-scroller > :not(.notion-page-content) { display: none !important; }'
style.innerHTML += '.notion-frame > .notion-scroller > :not(.notion-page-content) { display: none !important; }'
style.innerHTML += '.notion-scroller > div > div { padding-left: 0 !important; padding-right: 0 !important; }'
style.innerHTML += '.notion-cursor-listener { background: transparent !important; }'
style.innerHTML += '.notion-frame { background: transparent !important; }'
style.innerHTML += '.notion-collection_view-block > div { background: transparent !important; }'
style.innerHTML += '.notion-collection_view-block { overflow-x: hidden !important; }'
style.innerHTML += '.notion-collection_view-block > .notion-scroller { overflow: hidden !important; }'
style.innerHTML += 'body { background: transparent !important; }'
// Add the <style> element to the page
notionDoc.head.appendChild(style)
}
})
function closest(elem, selector) {
do {
if(elem.matches && elem.matches(selector))
return elem
elem = elem.parentNode
} while(elem)
}
{
notionDoc.addEventListener('click', e => {
const a = closest(e.target, 'a')
if (a) {
e.preventDefault()
e.stopImmediatePropagation()
open(a.href)
}
}, true)
}
})

View File

@ -1,5 +1,5 @@
// Requirements
const { app, BrowserWindow, ipcMain, Menu } = require('electron')
const { app, BrowserWindow, ipcMain, Menu, shell } = require('electron')
const autoUpdater = require('electron-updater').autoUpdater
const ejse = require('ejs-electron')
const fs = require('fs')
@ -147,6 +147,16 @@ function createWindow() {
c({cancel: false, responseHeaders: d.responseHeaders});
}
)
// Open web browser on new window
const handleRedirect = async (e, url) => {
if(url !== win.webContents.getURL()) {
e.preventDefault()
await shell.openExternal(url)
}
}
win.webContents.on('will-navigate', handleRedirect)
win.webContents.on('new-window', handleRedirect)
}
function createMenu() {