From 64579a08a4625915c1ad42a054d7b4ce0c058698 Mon Sep 17 00:00:00 2001 From: Kamesuta <kamesuta@gmail.com> Date: Thu, 19 Aug 2021 21:21:18 +0900 Subject: [PATCH] =?UTF-8?q?Notion=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/css/launcher.css | 22 ------ app/assets/js/scripts/landing.js | 126 ------------------------------- app/landing.ejs | 8 -- index.js | 16 ---- 4 files changed, 172 deletions(-) diff --git a/app/assets/css/launcher.css b/app/assets/css/launcher.css index a499356..19c5b08 100644 --- a/app/assets/css/launcher.css +++ b/app/assets/css/launcher.css @@ -4754,25 +4754,3 @@ form[name='submitSecretQuestion'] p { .rotatingBack { animation: rotatingBack 25s linear infinite; } - -/* Notion */ -#notionContainer { - margin-top: 120px; - width: 100%; - height: calc(100% - 120px); - overflow: hidden; -} - -#notion { - width: calc(100% / 0.65); - height: calc(100% / 0.65); - border: 0; - - zoom: 1; - -moz-transform: scale(0.65); - -moz-transform-origin: 0 0; - -o-transform: scale(0.65); - -o-transform-origin: 0 0; - -webkit-transform: scale(0.65); - -webkit-transform-origin: 0 0; -} diff --git a/app/assets/js/scripts/landing.js b/app/assets/js/scripts/landing.js index 38f3f45..c15e0ec 100644 --- a/app/assets/js/scripts/landing.js +++ b/app/assets/js/scripts/landing.js @@ -22,10 +22,8 @@ const launch_details_text = document.getElementById('launch_details_text') const server_selection_button = document.getElementById('server_selection_button') const server_selection_button_status = document.getElementById('server_selection_button_status') const user_text = document.getElementById('user_text') -const notion = document.getElementById('notion') const loggerLanding = LoggerUtil('%c[Landing]', 'color: #000668; font-weight: bold') -const logger = LoggerUtil('%c[NotionLoader]', 'color: #a02d2a; font-weight: bold') /* Launch Progress Wrapper Functions */ @@ -136,9 +134,6 @@ function updateSelectedAccount(authUser){ if(authUser.uuid != null){ document.getElementById('avatarContainer').style.backgroundImage = `url('https://crafatar.com/renders/body/${authUser.uuid}?overlay')` } - if (DistroManager.fetchNews !== undefined) { - DistroManager.fetchNews() - } } user_text.innerHTML = username } @@ -1292,124 +1287,3 @@ document.getElementById('settingsFileSystemButton').onclick = () => { DropinModUtil.validateDir(CACHE_SETTINGS_MODS_DIR) shell.openPath(CACHE_SETTINGS_MODS_DIR) } - -/** - * Fetch Notion URL - */ -function joinSession(uuid, accessToken, serverId) { - return new Promise((resolve, reject) => { - request.post('https://sessionserver.mojang.com/session/minecraft/join', - { - json: true, - body: { - selectedProfile: uuid, - accessToken, - serverId - } - }, - function (error, response, body) { - if (error) { - logger.error('Error during validation.', error) - reject(error) - } else { - if (response.statusCode === 403) { - resolve(false) - } else { - // 204 if valid - resolve(true) - } - } - }) - }) -} - -function fetchNotionURL(uuid, username) { - return new Promise((resolve, reject) => { - request.post('https://asia-northeast1-kuncraft.cloudfunctions.net/numalauncher-news', - { - json: true, - body: { - uuid, - username - } - }, - function (error, response, body) { - if (error) { - logger.error('Error during validation.', error) - reject(error) - } else { - resolve(body) - } - }) - }) -} - -DistroManager.fetchNews = async function() { - const serverId = 'numalauncher-news' - const {uuid, displayName, accessToken} = ConfigManager.getSelectedAccount() - if (await joinSession(uuid, accessToken, serverId)) { - const news = await fetchNotionURL(uuid, displayName) - notion.src = news.url - - if (news.pack !== undefined) { - DistroManager.distroURL = news.pack - DistroManager.pullRemote(news.pack).then((data) => { - logger.log('Loaded custom distribution index.') - - DistroManager.onDistroLoad = (data) => {} - DistroManager.onCustomDistroLoad(data) - - }) - } - } -} -DistroManager.fetchNews() - -/** - * Notion injection - */ -notion.contentWindow.localStorage.setItem('theme','{"mode":"dark"}') -notion.onload = (() => { - const notionDoc = notion.contentWindow.document - - // CSS - { - // Create the <style> tag - const style = notionDoc.createElement('style') - - 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-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; }' - style.innerHTML += '.notion-page-content { color: #ffffff !important; }' - style.innerHTML += '.notion-selectable { color: #ffffff !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) - } -}) diff --git a/app/landing.ejs b/app/landing.ejs index 36f2ff4..be655ce 100644 --- a/app/landing.ejs +++ b/app/landing.ejs @@ -7,14 +7,6 @@ </div> </div> <div id="content"> - <div id="notionContainer"> - <iframe - id="notion" - src="about:blank" - allowtransparency="allowtransparency" - > - </iframe> - </div> </div> <div id="right"> <div id="rightContainer"> diff --git a/index.js b/index.js index d52f581..86c90c4 100644 --- a/index.js +++ b/index.js @@ -372,22 +372,6 @@ function createWindow() { win = null }) - // We set an intercept on incoming requests to disable x-frame-options - // headers. - win.webContents.session.webRequest.onHeadersReceived({ urls: [ 'https://www.notion.so/teamkun/*' ] }, - (d, c)=>{ - if(d.responseHeaders['X-Frame-Options']){ - delete d.responseHeaders['X-Frame-Options'] - } else if(d.responseHeaders['x-frame-options']) { - delete d.responseHeaders['x-frame-options'] - } - - d.responseHeaders['Access-Control-Allow-Origin'] = ['null'] - - c({cancel: false, responseHeaders: d.responseHeaders}) - } - ) - // Open web browser on new window const handleRedirect = async (e, url) => { if(url !== win.webContents.getURL()) {