diff options
-rw-r--r-- | recipes/franz-custom-website/package.json | 2 | ||||
-rw-r--r-- | recipes/franz-custom-website/webview.js | 23 |
2 files changed, 23 insertions, 2 deletions
diff --git a/recipes/franz-custom-website/package.json b/recipes/franz-custom-website/package.json index d9f9f70..d3dcbba 100644 --- a/recipes/franz-custom-website/package.json +++ b/recipes/franz-custom-website/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "franz-custom-website", | 2 | "id": "franz-custom-website", |
3 | "name": "Custom Website", | 3 | "name": "Custom Website", |
4 | "version": "1.2.0", | 4 | "version": "1.3.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "repository": "https://github.com/meetfranz/recipe-custom-website", | 6 | "repository": "https://github.com/meetfranz/recipe-custom-website", |
7 | "config": { | 7 | "config": { |
diff --git a/recipes/franz-custom-website/webview.js b/recipes/franz-custom-website/webview.js index afe3605..072fed5 100644 --- a/recipes/franz-custom-website/webview.js +++ b/recipes/franz-custom-website/webview.js | |||
@@ -4,6 +4,27 @@ function _interopRequireDefault(obj) { | |||
4 | return obj && obj.__esModule ? obj : { default: obj }; | 4 | return obj && obj.__esModule ? obj : { default: obj }; |
5 | } | 5 | } |
6 | 6 | ||
7 | module.exports = Ferdium => { | 7 | module.exports = (Ferdium, settings) => { |
8 | Ferdium.injectCSS(_path.default.join(__dirname, 'style.css')); | 8 | Ferdium.injectCSS(_path.default.join(__dirname, 'style.css')); |
9 | |||
10 | // TODO: See how this can be moved into the main ferdium app and sent as an ipc message for opening with a new window or same Ferdium recipe's webview based on user's preferences | ||
11 | document.addEventListener('click', event => { | ||
12 | const link = event.target.closest('a[href^="http"]'); | ||
13 | const button = event.target.closest('button[title^="http"]'); | ||
14 | |||
15 | if (link || button) { | ||
16 | const url = link ? link.getAttribute('href') : button.getAttribute('title'); | ||
17 | |||
18 | if (!Ferdium.isImage(link)) { | ||
19 | event.preventDefault(); | ||
20 | event.stopPropagation(); | ||
21 | |||
22 | if (settings.trapLinkClicks === true) { | ||
23 | window.location.href = url; | ||
24 | } else { | ||
25 | Ferdium.openNewWindow(url); | ||
26 | } | ||
27 | } | ||
28 | } | ||
29 | }, true); | ||
9 | }; | 30 | }; |