diff options
Diffstat (limited to 'recipes/telegram')
-rw-r--r-- | recipes/telegram/package.json | 2 | ||||
-rw-r--r-- | recipes/telegram/webview.js | 23 |
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 | ||
7 | module.exports = Ferdium => { | 7 | module.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 | }; |