From 0a0dca6881d99a3b351c876689a9054e17d2e642 Mon Sep 17 00:00:00 2001 From: Talha Asghar Date: Thu, 15 Aug 2024 15:05:42 +0500 Subject: [PATCH] fix: #56 hide whole feed feature is now working again (#57) * fix: #56 hide whole feed feature is now working again * fix: dont hide feed on notifications page --- content/content.js | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/content/content.js b/content/content.js index d6861b2..3925eaa 100644 --- a/content/content.js +++ b/content/content.js @@ -170,27 +170,26 @@ function getStorageAndDoIt() { async function toggleFeed(shown) { let attempts = 0 let success = false - + let className = 'scaffold-finite-scroll__content' // feed element css class + if (window.location.href != 'https://www.linkedin.com/feed/'){ + // dont hide this element on notifications & jobs page. Only hide on home feed instead. + return + } while (!success && attempts < 50) { await new Promise((resolve) => { - setTimeout(() => { - if ( - document.getElementsByClassName('artdeco-dropdown') && - document.getElementsByClassName('artdeco-dropdown')[1] && - document.getElementsByClassName('artdeco-dropdown')[1] - .nextElementSibling - ) { - if (shown) { - document - .getElementsByClassName('artdeco-dropdown')[1] - .nextElementSibling.classList.add('hide') - } else { - document - .getElementsByClassName('artdeco-dropdown')[1] - .nextElementSibling.classList.remove('hide', 'dim') - } - success = true + setTimeout(() => { + if (shown) { + document + .getElementsByClassName(className).item(0) + .classList.add('hide') + console.log(`LinkOff: feed disabled`) + } else { + document + .getElementsByClassName(className).item(0) + .classList.remove('hide') + console.log(`LinkOff: feed enabled`) } + success = true attempts = attempts + 1 resolve() }, 100 + attempts * 10)