blob: 7b36b1a65d8963c5223e49a7dfc7c7142c15725e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { default: obj };
}
const _path = _interopRequireDefault(require('path'));
module.exports = Ferdium => {
const getMessages = () => {
const elements = document.querySelectorAll(
'#HeaderUserActions--Messages > a > span',
);
let count = 0;
if (elements[0]) {
count = Ferdium.safeParseInt(elements[0].textContent);
}
Ferdium.setBadge(count);
};
Ferdium.loop(getMessages);
// Use CSS to hide Google Ads
Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
Ferdium.handleDarkMode(isEnabled => {
// Open dropdown menu if not already open
const menu = document.querySelector('#USER_DROPDOWN_ID');
if (menu && menu.getAttribute('aria-expanded') === 'false') {
menu.click();
}
setTimeout(() => {
// Check if service is already in right mode
const btn = document.querySelector('[role=menu] button button');
const checked = btn && btn.getAttribute('aria-checked') === 'true';
if (
((checked && !isEnabled) || (!checked && isEnabled)) && // Click the button to switch between modes
btn
) {
btn.click();
}
}, 50);
});
};
|