aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Vijay A <vraravam@users.noreply.github.com>2022-10-10 11:29:51 +0530
committerLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2022-10-10 11:48:49 +0530
commitb92f4cda81630746610d9b09e4fc24dc9dc3853c (patch)
treec7df46992bf0890032dc19077d07b71b5462d432
parentKimai recipe now has the option for a custom domain (diff)
downloadferdium-recipes-b92f4cda81630746610d9b09e4fc24dc9dc3853c.tar.gz
ferdium-recipes-b92f4cda81630746610d9b09e4fc24dc9dc3853c.tar.zst
ferdium-recipes-b92f4cda81630746610d9b09e4fc24dc9dc3853c.zip
Telegram links can open within Ferdium instead of default browser
-rw-r--r--recipes/telegram/package.json2
-rw-r--r--recipes/telegram/webview.js23
2 files changed, 23 insertions, 2 deletions
diff --git a/recipes/telegram/package.json b/recipes/telegram/package.json
index f873bb6..80bed06 100644
--- a/recipes/telegram/package.json
+++ b/recipes/telegram/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "telegram", 2 "id": "telegram",
3 "name": "Telegram", 3 "name": "Telegram",
4 "version": "3.3.4", 4 "version": "3.3.5",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://web.telegram.org", 7 "serviceURL": "https://web.telegram.org",
diff --git a/recipes/telegram/webview.js b/recipes/telegram/webview.js
index 544a573..288160a 100644
--- a/recipes/telegram/webview.js
+++ b/recipes/telegram/webview.js
@@ -4,7 +4,7 @@ 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 const telegramVersion = document 8 const telegramVersion = document
9 .querySelector('meta[property="og:url"]') 9 .querySelector('meta[property="og:url"]')
10 ?.getAttribute('content'); 10 ?.getAttribute('content');
@@ -82,4 +82,25 @@ module.exports = Ferdium => {
82 Ferdium.loop(loopFunc); 82 Ferdium.loop(loopFunc);
83 83
84 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); 84 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
85
86 // 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
87 document.addEventListener('click', event => {
88 const link = event.target.closest('a[href^="http"]');
89 const button = event.target.closest('button[title^="http"]');
90
91 if (link || button) {
92 const url = link ? link.getAttribute('href') : button.getAttribute('title');
93
94 if (!Ferdium.isImage(link)) {
95 event.preventDefault();
96 event.stopPropagation();
97
98 if (settings.trapLinkClicks === true) {
99 window.location.href = url;
100 } else {
101 Ferdium.openNewWindow(url);
102 }
103 }
104 }
105 }, true);
85}; 106};