Last active
November 19, 2024 20:13
-
-
Save jaxley/6d340ca59360d94a8338dfb5e0c2a33b to your computer and use it in GitHub Desktop.
A simple script to streamline job postings on Linkedin by hiding those from a configurable list of companies.
This file contains hidden or 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
// ==UserScript== | |
// @name LinkedIn Company Filter | |
// @namespace http://axley.net/ | |
// @version 0.1 | |
// @description Simple, configurable filter to ignore job postings from companies you've ruled out | |
// @author You | |
// @match https://www.linkedin.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=linkedin.com | |
// @grant GM_getValue | |
// @grant GM_setValue | |
// @grant GM.getValue | |
// @grant GM.setValue | |
// @grant GM_registerMenuCommand | |
// @run-at document-end | |
// @downloadURL https://gist.github.com/jaxley/6d340ca59360d94a8338dfb5e0c2a33b/raw/eee97d32c231f25651b6d49fbb6e3b33823402e5/linkedin-filter.user.js | |
// @updateURL https://gist.github.com/jaxley/6d340ca59360d94a8338dfb5e0c2a33b | |
// @require https://openuserjs.org/src/libs/sizzle/GM_config.js | |
// ==/UserScript== | |
(async function() { | |
'use strict'; | |
const cfg = new GM_config({ | |
id: 'LinkedInFilterConfig', | |
title: 'Script Settings', // Panel Title | |
fields: { | |
'blockedCompanies': // This is the id of the field | |
{ | |
'label': 'Blocked Companies', // Appears next to field | |
'type': 'string', // Makes this setting a text field | |
'default': ["Gusto", | |
"Costco Wholesale", | |
"Grubhub", "DoorDash", | |
"Uber", | |
"Snap Inc.", | |
"Coinbase", | |
"Rippling", | |
"Starbucks", | |
"Meta", | |
"Peloton Interactive"] | |
} | |
} | |
}); | |
cfg.onSave(() => prune(cfg.get('blockedCompanies'))); | |
const container = document.querySelector("body"); | |
const observerOptions = { | |
childList: true, | |
subtree: true, | |
}; | |
async function prune(blockedCompanies) { | |
let nodesToPrune = document.getElementsByClassName("job-card-container__primary-description"); | |
if (blockedCompanies && blockedCompanies.length > 0) { | |
blockedCompanies = blockedCompanies.split(','); | |
} | |
for(let i = 0 ; i<nodesToPrune.length ; i++){ | |
const node = nodesToPrune[i]; | |
//console.log(`Processing node: ${node.innerText}`); | |
if (blockedCompanies.includes(node.innerText)) { | |
console.log(`Nuking node: ${node.innerText}`); | |
const closest = node.closest(".discovery-templates-entity-item") || node.closest(".jobs-search-results__list-item") | |
if (closest) { | |
closest.style.cssText += 'display:none'; | |
} else { | |
console.log(`Node ${node.innerText} closest parent not found.`); | |
} | |
} | |
} | |
} | |
const observer = new MutationObserver((one, two) => prune(cfg.get('blockedCompanies'))); | |
observer.observe(container, observerOptions); | |
GM_registerMenuCommand("Change settings", function(event) { | |
cfg.open(); | |
}, { | |
autoClose: true | |
}); | |
prune(cfg.get('blockedCompanies')); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment