Last active
January 21, 2018 16:59
-
-
Save SamDudley/0ca0792299aba81414d3a7bea4a2db54 to your computer and use it in GitHub Desktop.
Hides all the sponsered job search results shown by indeed.
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
function hideAllSponseredResults() { | |
// A little helper function to convert node lists returned from querySelector | |
// to a proper array so we can use methods like filter. | |
function toArray(nodeList) { | |
let array = [] | |
nodeList.forEach(node => array.push(node)) | |
return array | |
} | |
// Find all the results. | |
let results = toArray(document.querySelectorAll('#resultsCol div.row.result')) | |
// Filter the results down to just the sponsored results. | |
let sponsored = results.filter(result => { | |
// This is how I am testing for a sponsored result. | |
return result.querySelector('.sponsoredGray') !== null | |
}) | |
// Loop over each sponsored result and hide it. | |
sponsored.forEach(el => el.style.display = 'none') | |
} | |
// Run our function. | |
hideAllSponseredResults() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment