diff options
author | Markus Hatvan <markus_hatvan@aon.at> | 2021-10-05 17:04:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-10-05 17:04:09 +0200 |
commit | d3841b766f9d37d557646003899f67525c5f755f (patch) | |
tree | 1bcab990c94f2b05678b7a83ffebe08298500f0b /recipes/reddit/webview.js | |
parent | chore: repo maintenance (#732) (diff) | |
download | ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.tar.gz ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.tar.zst ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.zip |
chore: add eslint-plugin-unicorn (#733)
Diffstat (limited to 'recipes/reddit/webview.js')
-rw-r--r-- | recipes/reddit/webview.js | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/recipes/reddit/webview.js b/recipes/reddit/webview.js index 5095ba1..8d165aa 100644 --- a/recipes/reddit/webview.js +++ b/recipes/reddit/webview.js | |||
@@ -12,16 +12,21 @@ module.exports = Ferdi => { | |||
12 | let count = 0; | 12 | let count = 0; |
13 | 13 | ||
14 | if (elements[0]) { | 14 | if (elements[0]) { |
15 | count = Ferdi.safeParseInt(elements[0].innerHTML); | 15 | count = Ferdi.safeParseInt(elements[0].textContent); |
16 | } | 16 | } |
17 | 17 | ||
18 | Ferdi.setBadge(count); | 18 | Ferdi.setBadge(count); |
19 | }; | 19 | }; |
20 | 20 | ||
21 | if (document.querySelectorAll('.promotedlink').length > 0) { | 21 | if (document.querySelectorAll('.promotedlink').length > 0) { |
22 | document.querySelectorAll('.promotedlink').forEach(sponsoredLink => { | 22 | for (const sponsoredLink of document.querySelectorAll('.promotedlink')) { |
23 | sponsoredLink.parentElement.parentElement.style.display = 'none'; | 23 | if ( |
24 | }); | 24 | sponsoredLink.parentElement && |
25 | sponsoredLink.parentElement.parentElement | ||
26 | ) { | ||
27 | sponsoredLink.parentElement.parentElement.style.display = 'none'; | ||
28 | } | ||
29 | } | ||
25 | } | 30 | } |
26 | 31 | ||
27 | Ferdi.loop(getMessages); | 32 | Ferdi.loop(getMessages); |
@@ -41,8 +46,10 @@ module.exports = Ferdi => { | |||
41 | const btn = document.querySelector('[role=menu] button button'); | 46 | const btn = document.querySelector('[role=menu] button button'); |
42 | const checked = btn && btn.getAttribute('aria-checked') === 'true'; | 47 | const checked = btn && btn.getAttribute('aria-checked') === 'true'; |
43 | 48 | ||
44 | if ((checked && !isEnabled) || (!checked && isEnabled)) { | 49 | if ( |
45 | // Click the button to switch between modes | 50 | ((checked && !isEnabled) || (!checked && isEnabled)) && // Click the button to switch between modes |
51 | btn | ||
52 | ) { | ||
46 | btn.click(); | 53 | btn.click(); |
47 | } | 54 | } |
48 | }, 50); | 55 | }, 50); |