diff options
Diffstat (limited to 'recipes/messenger')
-rw-r--r-- | recipes/messenger/index.js | 13 | ||||
-rw-r--r-- | recipes/messenger/package.json | 2 | ||||
-rw-r--r-- | recipes/messenger/webview.js | 36 |
3 files changed, 36 insertions, 15 deletions
diff --git a/recipes/messenger/index.js b/recipes/messenger/index.js index 425683a..0f18b4f 100644 --- a/recipes/messenger/index.js +++ b/recipes/messenger/index.js | |||
@@ -1,5 +1,8 @@ | |||
1 | module.exports = (Ferdium) => class Messenger extends Ferdium { | 1 | module.exports = Ferdium => |
2 | overrideUserAgent() { | 2 | class Messenger extends Ferdium { |
3 | return window.navigator.userAgent.replace(/(Ferdium|Electron)\/\S+ \([^)]+\)/g, '').trim(); | 3 | overrideUserAgent() { |
4 | } | 4 | return window.navigator.userAgent |
5 | }; | 5 | .replaceAll(/(Ferdium|Electron)\/\S+ \([^)]+\)/g, '') |
6 | .trim(); | ||
7 | } | ||
8 | }; | ||
diff --git a/recipes/messenger/package.json b/recipes/messenger/package.json index 2e8bdec..3b5783c 100644 --- a/recipes/messenger/package.json +++ b/recipes/messenger/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "messenger", | 2 | "id": "messenger", |
3 | "name": "Messenger", | 3 | "name": "Messenger", |
4 | "version": "1.7.7", | 4 | "version": "1.8.0", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://messenger.com", | 7 | "serviceURL": "https://messenger.com", |
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({ |