diff options
author | 2021-10-05 16:46:55 +0200 | |
---|---|---|
committer | 2021-10-05 16:46:55 +0200 | |
commit | 2484c63d77e05fff384cc08b6ea46a29a22a62ec (patch) | |
tree | 21b8b74f1788407a4cfb13052160398f13424ac6 /recipes/reddit/webview.js | |
parent | Add check to ensure that generated file 'user.js' is not present in default p... (diff) | |
download | ferdium-recipes-2484c63d77e05fff384cc08b6ea46a29a22a62ec.tar.gz ferdium-recipes-2484c63d77e05fff384cc08b6ea46a29a22a62ec.tar.zst ferdium-recipes-2484c63d77e05fff384cc08b6ea46a29a22a62ec.zip |
chore: repo maintenance (#732)
Diffstat (limited to 'recipes/reddit/webview.js')
-rw-r--r-- | recipes/reddit/webview.js | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/recipes/reddit/webview.js b/recipes/reddit/webview.js index 327bd89..5095ba1 100644 --- a/recipes/reddit/webview.js +++ b/recipes/reddit/webview.js | |||
@@ -1,10 +1,14 @@ | |||
1 | const _path = _interopRequireDefault(require('path')); | 1 | const _path = _interopRequireDefault(require('path')); |
2 | 2 | ||
3 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | 3 | function _interopRequireDefault(obj) { |
4 | return obj && obj.__esModule ? obj : { default: obj }; | ||
5 | } | ||
4 | 6 | ||
5 | module.exports = (Ferdi) => { | 7 | module.exports = Ferdi => { |
6 | const getMessages = () => { | 8 | const getMessages = () => { |
7 | const elements = document.querySelectorAll('#HeaderUserActions--Messages > a > span'); | 9 | const elements = document.querySelectorAll( |
10 | '#HeaderUserActions--Messages > a > span', | ||
11 | ); | ||
8 | let count = 0; | 12 | let count = 0; |
9 | 13 | ||
10 | if (elements[0]) { | 14 | if (elements[0]) { |
@@ -15,7 +19,7 @@ module.exports = (Ferdi) => { | |||
15 | }; | 19 | }; |
16 | 20 | ||
17 | if (document.querySelectorAll('.promotedlink').length > 0) { | 21 | if (document.querySelectorAll('.promotedlink').length > 0) { |
18 | document.querySelectorAll('.promotedlink').forEach((sponsoredLink) => { | 22 | document.querySelectorAll('.promotedlink').forEach(sponsoredLink => { |
19 | sponsoredLink.parentElement.parentElement.style.display = 'none'; | 23 | sponsoredLink.parentElement.parentElement.style.display = 'none'; |
20 | }); | 24 | }); |
21 | } | 25 | } |
@@ -25,17 +29,17 @@ module.exports = (Ferdi) => { | |||
25 | // Use CSS to hide Google Ads | 29 | // Use CSS to hide Google Ads |
26 | Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); | 30 | Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); |
27 | 31 | ||
28 | Ferdi.handleDarkMode((isEnabled, config) => { | 32 | Ferdi.handleDarkMode(isEnabled => { |
29 | // Open dropdown menu if not already open | 33 | // Open dropdown menu if not already open |
30 | const menu = document.querySelector('#USER_DROPDOWN_ID'); | 34 | const menu = document.querySelector('#USER_DROPDOWN_ID'); |
31 | if (menu.getAttribute('aria-expanded') === 'false') { | 35 | if (menu && menu.getAttribute('aria-expanded') === 'false') { |
32 | menu.click(); | 36 | menu.click(); |
33 | } | 37 | } |
34 | 38 | ||
35 | setTimeout(() => { | 39 | setTimeout(() => { |
36 | // Check if service is already in right mode | 40 | // Check if service is already in right mode |
37 | const btn = document.querySelector('[role=menu] button button'); | 41 | const btn = document.querySelector('[role=menu] button button'); |
38 | const checked = btn.getAttribute('aria-checked') === 'true'; | 42 | const checked = btn && btn.getAttribute('aria-checked') === 'true'; |
39 | 43 | ||
40 | if ((checked && !isEnabled) || (!checked && isEnabled)) { | 44 | if ((checked && !isEnabled) || (!checked && isEnabled)) { |
41 | // Click the button to switch between modes | 45 | // Click the button to switch between modes |