Skip to content

Instantly share code, notes, and snippets.

@SebastienWae
Last active December 1, 2022 21:38
Show Gist options
  • Save SebastienWae/baebf8f4a3a9094055dbb3b871559f2c to your computer and use it in GitHub Desktop.
Save SebastienWae/baebf8f4a3a9094055dbb3b871559f2c to your computer and use it in GitHub Desktop.
LinkedIn jobs hide promoted
{
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