aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/franz-custom-website/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/franz-custom-website/webview.js')
-rw-r--r--recipes/franz-custom-website/webview.js23
1 files changed, 22 insertions, 1 deletions
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
7module.exports = Ferdium => { 7module.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};