aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/reddit/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/reddit/webview.js')
-rw-r--r--recipes/reddit/webview.js19
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);