From 04b52afc6bd2de62c991a6bef3c185be8697bcca Mon Sep 17 00:00:00 2001 From: Dominik Guzei Date: Wed, 2 Oct 2019 17:56:02 +0200 Subject: Fixes #1609 by adding special handling for skype links --- src/webview/recipe.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/webview/recipe.js') diff --git a/src/webview/recipe.js b/src/webview/recipe.js index c223b73de..60660d8f1 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js @@ -32,7 +32,7 @@ class RecipeController { 'settings-update': 'updateAppSettings', 'service-settings-update': 'updateServiceSettings', 'get-service-id': 'serviceIdEcho', - } + }; constructor() { this.initialize(); @@ -174,6 +174,32 @@ new RecipeController(); const originalWindowOpen = window.open; window.open = (url, frameName, features) => { + if (!url && !frameName && !features) { + // The service hasn't yet supplied a URL (as used in Skype). + // Return a new dummy window object and wait for the service to change the properties + const newWindow = { + location: { + href: '', + }, + }; + + const checkInterval = setInterval(() => { + // Has the service changed the URL yet? + if (newWindow.location.href !== '') { + // Open the new URL + ipcRenderer.sendToHost('new-window', newWindow.location.href); + clearInterval(checkInterval); + } + }, 0); + + setTimeout(() => { + // Stop checking for location changes after 1 second + clearInterval(checkInterval); + }, 1000); + + return newWindow; + } + // We need to differentiate if the link should be opened in a popup or in the systems default browser if (!frameName && !features) { return ipcRenderer.sendToHost('new-window', url); -- cgit v1.2.3-54-g00ecf From a564a35bcf9bcfedd6dc7bc60ce2c115badd6985 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Wed, 2 Oct 2019 21:39:03 +0200 Subject: Use native window.open --- src/webview/recipe.js | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src/webview/recipe.js') diff --git a/src/webview/recipe.js b/src/webview/recipe.js index c223b73de..7be307f05 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js @@ -169,15 +169,3 @@ class RecipeController { /* eslint-disable no-new */ new RecipeController(); /* eslint-enable no-new */ - -// Patching window.open -const originalWindowOpen = window.open; - -window.open = (url, frameName, features) => { - // We need to differentiate if the link should be opened in a popup or in the systems default browser - if (!frameName && !features) { - return ipcRenderer.sendToHost('new-window', url); - } - - return originalWindowOpen(url, frameName, features); -}; -- cgit v1.2.3-54-g00ecf From d390f216c3e0ecd38067d19da8bd882e6a0303a7 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Thu, 3 Oct 2019 13:51:00 +0200 Subject: re-fix & improve new-window handling --- src/webview/recipe.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/webview/recipe.js') diff --git a/src/webview/recipe.js b/src/webview/recipe.js index 7be307f05..e1ff44f05 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js @@ -12,6 +12,7 @@ import contextMenu from './contextMenu'; import './notifications'; import { DEFAULT_APP_SETTINGS } from '../config'; +import { isDevMode } from '../environment'; const debug = require('debug')('Franz:Plugin'); @@ -169,3 +170,17 @@ class RecipeController { /* eslint-disable no-new */ new RecipeController(); /* eslint-enable no-new */ + +// Patching window.open +const originalWindowOpen = window.open; + + +window.open = (url, frameName, features) => { + debug('window.open', url, frameName, features); + // We need to differentiate if the link should be opened in a popup or in the systems default browser + if (!frameName && !features && typeof features !== 'string') { + return ipcRenderer.sendToHost('new-window', url); + } + + return originalWindowOpen(url, frameName, features); +}; -- cgit v1.2.3-54-g00ecf From faecce7f35b566e50224804108621ae6db4739ab Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Thu, 3 Oct 2019 13:51:16 +0200 Subject: Add `window.log` for easier logging in event mode --- src/webview/recipe.js | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/webview/recipe.js') diff --git a/src/webview/recipe.js b/src/webview/recipe.js index e1ff44f05..353eb31fd 100644 --- a/src/webview/recipe.js +++ b/src/webview/recipe.js @@ -184,3 +184,7 @@ window.open = (url, frameName, features) => { return originalWindowOpen(url, frameName, features); }; + +if (isDevMode) { + window.log = console.log; +} -- cgit v1.2.3-54-g00ecf