Last active
December 1, 2022 21:38
-
-
Save SebastienWae/baebf8f4a3a9094055dbb3b871559f2c to your computer and use it in GitHub Desktop.
LinkedIn jobs hide promoted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
const waitForContent = (job) => new Promise((resolve, reject) => { | |
let retries = 0; | |
(function loop() { | |
if (retries < 50) { | |
retries++; | |
setTimeout(() => { | |
if (job.innerText) { | |
resolve() | |
} else { | |
waitForContent(); | |
} | |
}, retries); | |
} else { | |
reject(); | |
} | |
})(); | |
}); | |
const hidePromoted = async (jobIt) => { | |
const job = jobIt.next().value; | |
if (job) { | |
job.scrollIntoView(); | |
try { | |
await waitForContent(job); | |
} | |
catch(e) { | |
console.error("too may retries", e, job); | |
} | |
const label = job.querySelector(".job-card-container__footer-item"); | |
label && label.innerText === "Promoted" && job.remove(); | |
hidePromoted(jobIt); | |
} else { | |
const first = document.querySelector(".jobs-search-results-list>ul>li"); | |
first && first.scrollIntoView(); | |
} | |
} | |
const jobs = document.querySelectorAll(".jobs-search-results-list>ul>li"); | |
hidePromoted(jobs[Symbol.iterator]()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment