Skip to content

Instantly share code, notes, and snippets.

@jportella93
Last active March 31, 2020 20:03
Show Gist options
  • Save jportella93/c435012aff08d9b1bc71c5bf65c0df5a to your computer and use it in GitHub Desktop.
Save jportella93/c435012aff08d9b1bc71c5bf65c0df5a to your computer and use it in GitHub Desktop.
Browser will scroll down, upvote all items and reload the page.
// Go to a profile, open javascript console (cmd + alt + j) and paste the following code
// or you can save it in handy snippet https://developers.google.com/web/tools/chrome-devtools/javascript/snippets
// Update this selectors as LinkedIn's layout is updated
const endorseBtnSelector = '.pv-skill-entity__featured-endorse-button-shared';
const openSkillsSectionBtnSelector = '.pv-skills-section__additional-skills';
const body = document.body,
html = document.documentElement;
const height = Math.max(body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight,
html.offsetHeight);
const somethingWrongTimer = setTimeout(() => {
alert(`hacktheplanet: 🤔 Something went wrong with this profile. Maybe it hasn't got any skill posted? Try scrolling to the skills section and running this script again. Reloading the page...`);
location.reload()
}, 5000)
let openSkillsSectionBtn;
(function scrollAndClick() {
if (!openSkillsSectionBtn) {
window.scrollTo(0, height / 2)
setTimeout(() => {
openSkillsSectionBtn = document.querySelector(openSkillsSectionBtnSelector)
scrollAndClick()
}, 300)
} else {
openSkillsSectionBtn.click()
const btns = document.querySelectorAll(endorseBtnSelector);
if (btns.length === 0) {
alert(`hacktheplanet: ❌❌❌ Nothing available to upvote. Maybe the skills are already upvoted or you can't access skills from this profile. Reloading...`)
} else {
const unpressedBtns = Array.from(btns).filter(btn => btn.getAttribute('aria-pressed') !== 'true')
if (unpressedBtns.length === 0) {
alert(`hacktheplanet: ✅ Every skill in this profile seems to have been endorsed. Reloading...`)
} else {
let votedCounter = 0;
for (let btn of unpressedBtns) {
if (btn.getAttribute('aria-pressed') !== 'true') {
btn.click();
votedCounter++;
}
}
alert(`hacktheplanet: ✅✅✅ ${votedCounter} skills upvoted! Reloading...`)
}
}
clearTimeout(somethingWrongTimer)
setTimeout(() => location.reload(), 3000)
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment