From f9e2d9926e4dff14df0f13858a9c695e2118a94e Mon Sep 17 00:00:00 2001 From: Vijay Aravamudhan Date: Wed, 26 Jul 2023 16:35:49 +0000 Subject: Improve lint setup (#400) * Use strict configuration of node/npm/pnpm * When generating a new recipe, string replace should handle all placeholders in a single file --- recipes/telegram/package.json | 2 +- recipes/telegram/webview.js | 58 +++++++++++++++++++++++++------------------ 2 files changed, 35 insertions(+), 25 deletions(-) (limited to 'recipes/telegram') diff --git a/recipes/telegram/package.json b/recipes/telegram/package.json index ba4da14..5f6a543 100644 --- a/recipes/telegram/package.json +++ b/recipes/telegram/package.json @@ -1,7 +1,7 @@ { "id": "telegram", "name": "Telegram", - "version": "3.4.0", + "version": "3.4.1", "license": "MIT", "config": { "serviceURL": "https://web.telegram.org", diff --git a/recipes/telegram/webview.js b/recipes/telegram/webview.js index 5a12adb..5126e7d 100644 --- a/recipes/telegram/webview.js +++ b/recipes/telegram/webview.js @@ -2,10 +2,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - const _path = _interopRequireDefault(require('path')); +const _path = _interopRequireDefault(require('path')); module.exports = (Ferdium, settings) => { - const telegramVersion = document.querySelector('meta[property="og:url"]')?.getAttribute('content'); + const telegramVersion = document + .querySelector('meta[property="og:url"]') + ?.getAttribute('content'); const isWebK = telegramVersion?.includes('/k/'); @@ -67,7 +69,9 @@ module.exports = (Ferdium, settings) => { const getActiveDialogTitle = () => { let element; - element = isWebK ? document.querySelector('.top .peer-title') : document.querySelector('.chat-list .ListItem .title > h3'); + element = isWebK + ? document.querySelector('.top .peer-title') + : document.querySelector('.chat-list .ListItem .title > h3'); Ferdium.setDialogTitle(element ? element.textContent : ''); }; @@ -82,27 +86,33 @@ module.exports = (Ferdium, settings) => { Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); // 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 - document.addEventListener('click', event => { - const link = event.target.closest('a[href^="http"]'); - const button = event.target.closest('button[title^="http"]'); - - if (link || button) { - const url = link ? link.getAttribute('href') : button.getAttribute('title'); - - if (!Ferdium.isImage(link)) { - event.preventDefault(); - event.stopPropagation(); - - if ( - settings.trapLinkClicks === true - || url.includes('t.me') - || url.includes('web.telegram.org') - ) { - window.location.href = url; - } else { - Ferdium.openNewWindow(url); + document.addEventListener( + 'click', + event => { + const link = event.target.closest('a[href^="http"]'); + const button = event.target.closest('button[title^="http"]'); + + if (link || button) { + const url = link + ? link.getAttribute('href') + : button.getAttribute('title'); + + if (!Ferdium.isImage(link)) { + event.preventDefault(); + event.stopPropagation(); + + if ( + settings.trapLinkClicks === true || + url.includes('t.me') || + url.includes('web.telegram.org') + ) { + window.location.href = url; + } else { + Ferdium.openNewWindow(url); + } } } - } - }, true); + }, + true, + ); }; -- cgit v1.2.3-54-g00ecf