Last active
August 8, 2024 18:07
-
-
Save TechWithTy/3b64a8734be8dc0a3ba311ed907cac18 to your computer and use it in GitHub Desktop.
Linked In Company Connector
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
// Delay duration in milliseconds | |
const delayDuration = 1000; | |
// Function to parse credits from the text | |
function parseCredits() { | |
const creditsElement = document.querySelector('.t-14.t-black--light .t-bold'); | |
if (creditsElement) { | |
const creditsText = creditsElement.textContent.trim(); // "10/250" | |
const [availableCredits, totalCredits] = creditsText.split('/').map(Number); // Parse the numbers | |
console.log(`Credits available: ${availableCredits}/${totalCredits}`); | |
return availableCredits; | |
} | |
return 0; // Default to 0 if unable to parse | |
} | |
// Function to handle the clicking process | |
function processInputBox(inputBoxes, index, clickCount, maxClicks) { | |
const inviteLimitMessage = document.querySelector('.artdeco-inline-feedback__message'); | |
if (inviteLimitMessage && inviteLimitMessage.textContent.includes('You’ve hit the invite limit')) { | |
console.log('Invite limit reached, stopping the process.'); | |
testInviteButtonClick(); | |
return; | |
} | |
if (index < inputBoxes.length && clickCount < maxClicks) { | |
const inputBox = inputBoxes[index]; | |
const clickAndProceed = () => { | |
if (!inputBox.checked) { | |
inputBox.click(); | |
clickCount++; | |
console.log(`Checkbox ${index + 1} clicked. Total clicks: ${clickCount}`); | |
if (clickCount % 5 === 0) { | |
const scrollContainer = document.querySelector('.scaffold-finite-scroll__content'); | |
if (scrollContainer) { | |
scrollContainer.scrollTop += 100; // Adjust scrolling as needed | |
console.log(`Scrolled after clicking 5 checkboxes. Total scrolls: ${clickCount / 5}`); | |
} | |
} | |
} | |
processInputBox(inputBoxes, index + 1, clickCount, maxClicks); | |
}; | |
setTimeout(clickAndProceed, delayDuration); | |
} else { | |
console.log('Finished processing input boxes or reached the available credits limit.'); | |
clickInviteButton(); | |
} | |
} | |
// Function to click the invite button | |
function clickInviteButton() { | |
const inviteButton = document.querySelector('.artdeco-button--primary'); | |
if (inviteButton) { | |
inviteButton.click(); | |
console.log('Clicked the invite button.'); | |
testInviteButtonClick(); | |
} else { | |
console.log('Invite button not found.'); | |
} | |
} | |
// Function to detect and handle dynamic loading | |
function loadMoreInvitations(maxClicks) { | |
const modal = document.querySelector('.artdeco-modal'); | |
if (modal) { | |
const newInputBoxes = modal.querySelectorAll('.ember-checkbox.ember-view'); | |
if (newInputBoxes.length > 0) { | |
console.log('New invitations loaded, continuing selection process.'); | |
processInputBox(newInputBoxes, 0, 0, maxClicks); | |
} else { | |
console.log('No more invitations to load in modal.'); | |
const scrollContainer = document.querySelector('.scaffold-finite-scroll__content'); | |
if (scrollContainer) { | |
scrollContainer.scrollTop += 100; // Attempt to scroll within the modal | |
} | |
setTimeout(() => loadMoreInvitations(maxClicks), 2000); // Retry after a delay | |
} | |
} | |
} | |
// Test function for invite button click | |
function testInviteButtonClick() { | |
console.log('Testing invite button click...'); | |
const inviteLimitMessage = document.querySelector('.artdeco-inline-feedback__message'); | |
if (inviteLimitMessage && inviteLimitMessage.textContent.includes('You’ve hit the invite limit')) { | |
console.log('Test passed: Invite limit message found.'); | |
} else { | |
console.log('Test failed: Invite limit message not found.'); | |
} | |
} | |
// Function to start the invitation button clicks | |
function startInvitationClicks() { | |
const maxClicks = parseCredits(); // Get max clicks from available credits | |
const inputBoxes = document.querySelectorAll('.ember-checkbox.ember-view'); | |
if (inputBoxes.length > 0) { | |
processInputBox(inputBoxes, 0, 0, maxClicks); | |
} else { | |
console.log('No input boxes found.'); | |
} | |
} | |
// Start the process | |
startInvitationClicks(); |
PArsed Credits and Submits
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added Parse For Available credits