diff options
author | MCMXC <16797721+mcmxcdev@users.noreply.github.com> | 2023-07-26 06:29:03 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-26 17:59:03 +0530 |
commit | 9b8f01716774a960073e944823ab727cc867a8f6 (patch) | |
tree | 732b83770baa78f5cf12776aaa33ce65bebfa418 /recipes/messenger/webview.js | |
parent | Add Excalidraw recipe (#393) (diff) | |
download | ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.tar.gz ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.tar.zst ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.zip |
chore: improve lint setup (#397)
- update eslint config to closely mirror the ones from ferdium-app
- add .eslintignore
- opt in to eslint `reportUnusedDisableDirectives` config option
- remove `trailingComma: all` from `prettier` config which is default in `prettier` v3
- autofix or disable a lot of lint issues throughout codebase
- add `volta` configuration to `package.json` to autoload correct `node` and `pnpm` versions
- upgrade all `eslint` and `prettier` related dependencies to latest
- update lint:fix npm script
- reformat touched files with prettier
- bumped up minor version for all recipes that have changes
- introduced injection of 'service.css' where it was missing in many recipes
---------
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'recipes/messenger/webview.js')
-rw-r--r-- | recipes/messenger/webview.js | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/recipes/messenger/webview.js b/recipes/messenger/webview.js index 7fc8ed6..39ea098 100644 --- a/recipes/messenger/webview.js +++ b/recipes/messenger/webview.js | |||
@@ -1,10 +1,16 @@ | |||
1 | function _interopRequireDefault(obj) { | ||
2 | return obj && obj.__esModule ? obj : { default: obj }; | ||
3 | } | ||
4 | |||
5 | const _path = _interopRequireDefault(require('path')); | ||
6 | |||
1 | function hideInstallMessage() { | 7 | function hideInstallMessage() { |
2 | const installMessage = document.querySelector('.usczdcwk'); | 8 | const installMessage = document.querySelector('.usczdcwk'); |
3 | if (installMessage) { | 9 | if (installMessage) { |
4 | installMessage.style.display = | 10 | installMessage.style.display = |
5 | installMessage.style.display != 'none' | 11 | installMessage.style.display === 'none' |
6 | ? 'none' | 12 | ? installMessage.style.display |
7 | : installMessage.style.display; | 13 | : 'none'; |
8 | } | 14 | } |
9 | } | 15 | } |
10 | 16 | ||
@@ -17,7 +23,9 @@ module.exports = Ferdium => { | |||
17 | * try the counting with the new UI | 23 | * try the counting with the new UI |
18 | */ | 24 | */ |
19 | for (let href of ['/', '/requests/', '/marketplace/']) { | 25 | for (let href of ['/', '/requests/', '/marketplace/']) { |
20 | const elem = document.querySelector(`a[href^='${href}t/'][role='link'][tabindex='0']`).ariaLabel; | 26 | const elem = document.querySelector( |
27 | `a[href^='${href}t/'][role='link'][tabindex='0']`, | ||
28 | ).ariaLabel; | ||
21 | if (elem) { | 29 | if (elem) { |
22 | newMessengerUI = true; | 30 | newMessengerUI = true; |
23 | const match = elem.match(/(\d+)/g); | 31 | const match = elem.match(/(\d+)/g); |
@@ -31,18 +39,26 @@ module.exports = Ferdium => { | |||
31 | * do the old counting if the interface is not the last one | 39 | * do the old counting if the interface is not the last one |
32 | */ | 40 | */ |
33 | if (!newMessengerUI) { | 41 | if (!newMessengerUI) { |
34 | count = [...document.querySelectorAll('.bp9cbjyn.j83agx80.owycx6da:not(.btwxx1t3)')] | 42 | count = [ |
43 | ...document.querySelectorAll( | ||
44 | '.bp9cbjyn.j83agx80.owycx6da:not(.btwxx1t3)', | ||
45 | ), | ||
46 | ] | ||
35 | .map(elem => { | 47 | .map(elem => { |
36 | const hasPing = !!elem.querySelector('.pq6dq46d.is6700om.qu0x051f.esr5mh6w.e9989ue4.r7d6kgcz.s45kfl79.emlxlaya.bkmhp75w.spb7xbtv.cyypbtt7.fwizqjfa'); | 48 | const hasPing = !!elem.querySelector( |
37 | const isMuted = !!elem.querySelector('.a8c37x1j.ms05siws.l3qrxjdp.b7h9ocf4.trssfv1o'); | 49 | '.pq6dq46d.is6700om.qu0x051f.esr5mh6w.e9989ue4.r7d6kgcz.s45kfl79.emlxlaya.bkmhp75w.spb7xbtv.cyypbtt7.fwizqjfa', |
50 | ); | ||
51 | const isMuted = !!elem.querySelector( | ||
52 | '.a8c37x1j.ms05siws.l3qrxjdp.b7h9ocf4.trssfv1o', | ||
53 | ); | ||
38 | 54 | ||
39 | return hasPing && !isMuted; | 55 | return hasPing && !isMuted; |
40 | }) | 56 | }) |
41 | .reduce((prev, curr) => prev + curr, 0); | 57 | .reduce((prev, curr) => prev + curr, 0); |
42 | 58 | ||
43 | /* | 59 | /* |
44 | * add count of message requests on top of notification counter | 60 | * add count of message requests on top of notification counter |
45 | */ | 61 | */ |
46 | const messageRequestsElement = document.querySelector('._5nxf'); | 62 | const messageRequestsElement = document.querySelector('._5nxf'); |
47 | if (messageRequestsElement) { | 63 | if (messageRequestsElement) { |
48 | count += Ferdium.safeParseInt(messageRequestsElement.textContent); | 64 | count += Ferdium.safeParseInt(messageRequestsElement.textContent); |
@@ -59,6 +75,8 @@ module.exports = Ferdium => { | |||
59 | 75 | ||
60 | Ferdium.loop(loopRoutine); | 76 | Ferdium.loop(loopRoutine); |
61 | 77 | ||
78 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
79 | |||
62 | localStorage.setItem( | 80 | localStorage.setItem( |
63 | '_cs_desktopNotifsEnabled', | 81 | '_cs_desktopNotifsEnabled', |
64 | JSON.stringify({ | 82 | JSON.stringify({ |