aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/franz-custom-website
diff options
context:
space:
mode:
authorLibravatar Vijay A <vraravam@users.noreply.github.com>2022-10-05 15:19:05 +0530
committerLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2022-10-05 15:21:52 +0530
commit36ab52af0714daae25d88a757c1622ce01763e36 (patch)
tree750867f8fad95aa80bdc32007ef87790112f6fe7 /recipes/franz-custom-website
parentrecipes: add initial SimpleLogin service (diff)
downloadferdium-recipes-36ab52af0714daae25d88a757c1622ce01763e36.tar.gz
ferdium-recipes-36ab52af0714daae25d88a757c1622ce01763e36.tar.zst
ferdium-recipes-36ab52af0714daae25d88a757c1622ce01763e36.zip
Allow custom recipe to trapLinks and open them within Ferdium
Diffstat (limited to 'recipes/franz-custom-website')
-rw-r--r--recipes/franz-custom-website/package.json2
-rw-r--r--recipes/franz-custom-website/webview.js23
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
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};