Last active
April 11, 2024 19:15
-
-
Save onlymice/628a8284c175fcd7505dc4565084a92b to your computer and use it in GitHub Desktop.
endorseAllSkills, easy to use function to indorse person's skills on Linkedin
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 to automatically endorse all skills on a LinkedIn profile page. | |
*/ | |
function endorseAllSkills() { | |
// Variable to control delay between clicks (in milliseconds) | |
var delayBetweenClicks = 500; // 0.5 seconds | |
// Function to wait for an element to load | |
function waitForElement(selector, callback) { | |
if (document.querySelector(selector)) { | |
callback(); | |
} else { | |
setTimeout(function () { | |
waitForElement(selector, callback); | |
}, 1000); | |
} | |
} | |
// Function to scroll to the bottom of the page | |
function scrollToBottom() { | |
if (window.location.href.endsWith('details/skills/')) { | |
window.scrollTo(0, document.body.scrollHeight); | |
} | |
} | |
// Main function to click all the buttons | |
function clickButtons() { | |
var btns = document.querySelectorAll(".pv2 > button.artdeco-button ") | |
for (let i = 0; i < btns.length; i++) { | |
if (btns[i].children[0].tagName == 'LI-ICON') { | |
continue; | |
} | |
var load_more = document.querySelector(".p5 > button.artdeco-button "); | |
if (load_more != null){ | |
load_more.click(); | |
btns = document.querySelectorAll(".pv2 > button.artdeco-button ") | |
} | |
setTimeout(function () { | |
console.log('Clicking button number: ' + (i + 1)); | |
btns[i].click(); | |
}, i * delayBetweenClicks + Math.random() * 500); // Add a random delay up to half a second | |
} | |
} | |
// Wait for the '.pvs-list' element to load before clicking the buttons | |
waitForElement('.pvs-list', clickButtons); | |
// Scroll to the bottom of the page every 5 seconds, but only if the URL ends with 'details/skills/' | |
setInterval(scrollToBottom, 5000); | |
} | |
// Run the function whenever the URL changes | |
(function () { | |
var oldURL = ''; | |
setInterval(function () { | |
if (window.location.href !== oldURL) { | |
oldURL = window.location.href; | |
endorseAllSkills(); | |
} | |
}, 1000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looks like ln updated some of their elements and it now might click on invites too...