Created
July 7, 2024 15:51
-
-
Save davidshumway/4df862a596df4c6cac72661e6e10342e to your computer and use it in GitHub Desktop.
LinkedIn job search GreaseMonkey script
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
// ==UserScript== | |
// @name LinkedIn | |
// @version 1 | |
// @grant GM_setValue | |
// @grant GM_getValue | |
// @include https://www.linkedin.com/jobs/search/* | |
// @include https://www.linkedin.com/jobs/collections/* | |
// ==/UserScript== | |
function remove() { | |
var x = document.getElementsByClassName('jobs-search-results__list-item'); | |
for (var i=0; i<x.length; i++) { | |
// Applied | |
var y = x[i].getElementsByClassName('job-card-container__footer-item'); | |
if (y) { | |
for (var j=0; j<y.lenJobSearch.user.jsgth; j++) { | |
if (y[j].innerText.trim().indexOf('Applied') != -1) { | |
x[i].style.display = 'none'; | |
} | |
} | |
} | |
} | |
} | |
setInterval(remove, 400); | |
function click_buttons() { | |
// artdeco-button artdeco-button--2 artdeco-button--primary ember-view | |
// "Done" button | |
var j = document.getElementsByClassName( | |
'artdeco-button artdeco-button--2 artdeco-button--primary ember-view mlA block' | |
); | |
if (j.length == 1) { | |
j[0].click(); | |
} | |
// "Submit application" button | |
var j = document.getElementsByClassName( | |
'artdeco-button artdeco-button--2 artdeco-button--primary ember-view' | |
); | |
for (i=0; i<j.length; i++) { | |
if (j[i].innerText.trim() == 'Submit application') { | |
j[i].click(); | |
break; | |
} | |
} | |
} | |
setInterval(click_buttons, 200); | |
// Add buttons to ignore permanently and for the next 30 days. | |
// Every 2 seconds, check to add new buttons | |
function checkIgn() { | |
var x = document.getElementsByClassName('job-card-container') | |
// current time in seconds | |
var today = (new Date().getTime() / 1000) | |
if (!x || x.length == 0) return; | |
for (var i=0; i<x.length; i++) { | |
var comp = x[i].getElementsByClassName('job-card-container__primary-description'); | |
if (!comp || comp.length != 1) continue; | |
comp = comp[0].innerText.trim(); | |
if (x[i].getAttribute('added-ignore')) { | |
continue; | |
} else { | |
x[i].setAttribute('added-ignore', 1); | |
} | |
var ignBtn = document.createElement('button'); | |
if (localStorage['ignore-' + comp]) { | |
var time = parseInt(localStorage['ignore-' + comp]); | |
// ignored time, e.g. 10 days ago | |
// 10 days ago + 30 days > today == true (ignore) | |
// 60 days ago + 30 days > today == false (don't ignore) | |
if (time + (86400*30) > today) { | |
// ignore | |
x[i].setAttribute('style', 'display:none !important;'); | |
continue; | |
} | |
// show ignore button (+show it was prev. ignored) | |
ignBtn.innerText = '[i+]'; | |
} else { | |
ignBtn.innerText = '[i]'; | |
} | |
ignBtn.comp = comp; | |
ignBtn.parent = x[i]; | |
ignBtn.style.width = '30px'; | |
ignBtn.style.backgroundColor = '#bbb'; | |
ignBtn.style.border = '1px solid #333'; | |
x[i].appendChild(ignBtn); | |
ignBtn.onmousedown = ignMouse; | |
ignBtn.onclick = addIgn; | |
// perm. ignore | |
var ignBtn = document.createElement('button'); | |
ignBtn.innerText = '[p]'; | |
ignBtn.comp = comp; | |
ignBtn.parent = x[i] | |
ignBtn.style.display = 'flex'; | |
ignBtn.style.width = '30px'; | |
ignBtn.style.backgroundColor = '#bbb'; | |
ignBtn.style.border = '1px solid #333'; | |
x[i].appendChild(ignBtn); | |
ignBtn.onmousedown = ignMouse; | |
ignBtn.onclick = addPermanentIgn; | |
} | |
} | |
function ignMouse() { | |
this.style.backgroundColor = 'LightGreen'; | |
} | |
function addIgn() { | |
// this - refers to ignore button | |
this.style.backgroundColor = 'LightGreen'; | |
localStorage['ignore-' + this.comp] = new Date().getTime() / 1000; | |
this.parent.setAttribute('style', 'display:none !important;'); | |
} | |
function addPermanentIgn() { | |
// this - refers to ignore button | |
this.style.backgroundColor = 'LightGreen'; | |
localStorage['ignore-' + this.comp] = 99999999999999; // (year 5138) + 30 days will always be > today | |
this.parent.setAttribute('style', 'display:none !important;'); | |
} | |
setInterval(checkIgn, 1000); | |
// Open one | |
function openLink(to, link) { | |
setTimeout(function() { | |
window.open(link); | |
}, to); | |
} | |
// Open all | |
var toOpen = [] | |
function openLinks(divs) { | |
if (divs.length == 0) { | |
var to = 0 | |
var offset = 0 | |
if (toOpen.length > 0) { | |
for (link of toOpen) { | |
openLink(to, link); | |
to += 2000 + (offset*500); | |
offset += 1; | |
} | |
toOpen = []; // reset | |
} | |
return; | |
} | |
var d = divs.shift(); | |
d.click(); | |
setTimeout(function() { | |
var x = document.getElementsByClassName('job-details-jobs-unified-top-card__company-name'); | |
if (x && x.length == 1) { | |
x = x[0].getElementsByTagName('a'); | |
if (x && x.length == 1) { | |
// Some companies don't have a page | |
toOpen.push(x[0].href); | |
} | |
openLinks(divs); // go to next | |
} | |
}, 200); | |
} | |
function clickNext(e) { | |
var toClick = []; | |
var compsToOpen = {}; | |
var x = document.getElementsByClassName('job-card-container') | |
// current time in seconds | |
var today = (new Date().getTime() / 1000) | |
if (!x || x.length == 0) return; | |
for (var i=0; i<x.length; i++) { | |
var comp = x[i].getElementsByClassName('job-card-container__primary-description'); | |
if (!comp || comp.length != 1) continue; | |
comp = comp[0].innerText.trim(); | |
if (localStorage['ignore-' + comp]) { | |
var time = parseInt(localStorage['ignore-' + comp]); | |
// ignored time, e.g. 10 days ago | |
// 10 days ago + 30 days > today == true (ignore) | |
// 60 days ago + 30 days > today == false (don't ignore) | |
if (time + (86400*30) > today) { | |
// ignore | |
x[i].setAttribute('style', 'display:none !important;'); | |
continue; | |
} | |
if (!compsToOpen.hasOwnProperty(comp)) { | |
compsToOpen[comp] = true; | |
toClick.push(x[i]); | |
} | |
} else { | |
if (!compsToOpen.hasOwnProperty(comp)) { | |
compsToOpen[comp] = true; | |
toClick.push(x[i]); | |
} | |
} | |
} | |
if (toClick.length > 0) { | |
openLinks(toClick); | |
} | |
} | |
var x1 = document.createElement('div'); | |
x1.setAttribute('style', 'position:absolute;left:0;top:50%;z-index:10000;'); | |
document.body.appendChild(x1); | |
var x2 = document.createElement('button'); | |
x2.innerText = 'Open all'; | |
x2.style.border = '1px solid black'; | |
x2.style.height = '40px'; | |
x2.style.width = '80px'; | |
// x2.style.cursor = 'pointer'; | |
x1.appendChild(x2); | |
x2.onmousedown = ignMouse; | |
x2.onmouseup = function(){this.style.backgroundColor = '';}; | |
x2.onclick = clickNext; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment