From cb2359f8b5a1838d14837c5946803d499b7bf78d Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sun, 21 Jun 2020 00:52:32 +1200 Subject: [PATCH 1/4] Better support for go to url --- src/renderer/store/modules/utils.js | 39 +++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/src/renderer/store/modules/utils.js b/src/renderer/store/modules/utils.js index d5fac977..c46b8a13 100644 --- a/src/renderer/store/modules/utils.js +++ b/src/renderer/store/modules/utils.js @@ -53,18 +53,37 @@ const actions = { return state.colorClasses[randomInt] }, - getVideoIdFromUrl ({ state }, url) { - console.log('checking for id') - console.log(url) - const rx = /^.*(?:(?:(you|hook)tu\.?be\/|v\/|vi\/|u\/\w\/|embed\/)|(?:(?:watch)?\?v(?:i)?=|&v(?:i)?=))([^#&?]*).*/ - - const match = url.match(rx) - - if (match) { - return match[2] - } else { + getVideoIdFromUrl (_, url) { + /** @type {URL} */ + let urlObject + try { + urlObject = new URL(url) + } catch (e) { return false } + + const extractors = [ + // anything with /watch?v= + function() { + if (urlObject.pathname === "/watch" && urlObject.searchParams.has("v")) { + return urlObject.searchParams.get("v") + } + }, + // youtu.be + function() { + if (urlObject.host === "youtu.be" && urlObject.pathname.match(/^\/[A-Za-z0-9_-]+$/)) { + return urlObject.pathname.slice(1) + } + }, + // cloudtube + function() { + if (urlObject.host.match(/^cadence\.(gq|moe)$/) && urlObject.pathname.match(/^\/cloudtube\/video\/[A-Za-z0-9_-]+$/)) { + return urlObject.pathname.slice("/cloudtube/video/".length) + } + } + ] + + return extractors.reduce((a, c) => a || c(), null) || false } } From 6615b5a96445dea0375784b7c767d469e44ec3ad Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sun, 21 Jun 2020 01:05:36 +1200 Subject: [PATCH 2/4] Lint --- src/renderer/store/modules/utils.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/renderer/store/modules/utils.js b/src/renderer/store/modules/utils.js index c46b8a13..680fb7c8 100644 --- a/src/renderer/store/modules/utils.js +++ b/src/renderer/store/modules/utils.js @@ -65,20 +65,20 @@ const actions = { const extractors = [ // anything with /watch?v= function() { - if (urlObject.pathname === "/watch" && urlObject.searchParams.has("v")) { - return urlObject.searchParams.get("v") + if (urlObject.pathname === '/watch' && urlObject.searchParams.has('v')) { + return urlObject.searchParams.get('v') } }, // youtu.be function() { - if (urlObject.host === "youtu.be" && urlObject.pathname.match(/^\/[A-Za-z0-9_-]+$/)) { + if (urlObject.host === 'youtu.be' && urlObject.pathname.match(/^\/[A-Za-z0-9_-]+$/)) { return urlObject.pathname.slice(1) } }, // cloudtube function() { if (urlObject.host.match(/^cadence\.(gq|moe)$/) && urlObject.pathname.match(/^\/cloudtube\/video\/[A-Za-z0-9_-]+$/)) { - return urlObject.pathname.slice("/cloudtube/video/".length) + return urlObject.pathname.slice('/cloudtube/video/'.length) } } ] From 6846126813f90c147a51529cf5f25c448aec2752 Mon Sep 17 00:00:00 2001 From: Airradda <3744856+Airradda@users.noreply.github.com> Date: Sun, 21 Jun 2020 20:31:59 -0500 Subject: [PATCH 3/4] Removed accidential scrollbar changes --- src/renderer/themes.css | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/src/renderer/themes.css b/src/renderer/themes.css index 8f39540b..df2320d9 100644 --- a/src/renderer/themes.css +++ b/src/renderer/themes.css @@ -448,14 +448,3 @@ a:link { a:visited { color: var(--link-visited-color); } -::-webkit-scrollbar { - width: 10px; -} -::-webkit-scrollbar-thumb { - -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.5); - background: var(--primary-color); - border-radius: 10px; -} -::-webkit-scrollbar-thumb:hover { - background: var(--primary-color-active); -} From 4bc5b1d6083322b6bbd6e363fe2fda3cae1d8a79 Mon Sep 17 00:00:00 2001 From: Preston Date: Sun, 21 Jun 2020 23:03:51 -0400 Subject: [PATCH 4/4] Allow more than one instance of the app. --- src/main/index.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index aae38455..9ea3a1e1 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -14,7 +14,7 @@ app.setName(productName) // disable electron warning process.env.ELECTRON_DISABLE_SECURITY_WARNINGS = 'true' -const gotTheLock = app.requestSingleInstanceLock() +// const gotTheLock = app.requestSingleInstanceLock() const isDev = process.env.NODE_ENV === 'development' const isDebug = process.argv.includes('--debug') let mainWindow @@ -24,25 +24,26 @@ let mainWindow // This line can possible be removed if the issue is fixed upstream app.commandLine.appendSwitch('disable-features', 'OutOfBlinkCors') +// TODO: Uncomment if needed // only allow single instance of application -if (!isDev) { - if (gotTheLock) { - app.on('second-instance', () => { - // Someone tried to run a second instance, we should focus our window. - if (mainWindow && mainWindow.isMinimized()) { - mainWindow.restore() - } - mainWindow.focus() - }) - } else { - app.quit() - process.exit(0) - } -} else { - require('electron-debug')({ - showDevTools: !(process.env.RENDERER_REMOTE_DEBUGGING === 'true') - }) -} +// if (!isDev) { +// if (gotTheLock) { +// app.on('second-instance', () => { +// // Someone tried to run a second instance, we should focus our window. +// if (mainWindow && mainWindow.isMinimized()) { +// mainWindow.restore() +// } +// mainWindow.focus() +// }) +// } else { +// app.quit() +// process.exit(0) +// } +// } else { +// require('electron-debug')({ +// showDevTools: !(process.env.RENDERER_REMOTE_DEBUGGING === 'true') +// }) +// } async function installDevTools () { try { @@ -70,7 +71,6 @@ function createWindow () { webSecurity: false, backgroundThrottling: false }, - show: false }) // eslint-disable-next-line