Posted 10 months ago
·
Author
Chrome Extension: https://chromewebstore.google.com/detai ... fdacpbcbam
Fully able to leave it running in the background.
Fully able to leave it running in the background.
function waitForElement(selector, timeout = 30000) {
return new Promise(function(resolve, reject) {
const intervalTime = 100;
let elapsedTime = 0;
const interval = setInterval(() => {
const element = document.querySelector(selector);
if (element) {
clearInterval(interval);
resolve(element);
} else if (elapsedTime >= timeout) {
clearInterval(interval);
reject(new Error(`Element ${selector} not found within ${timeout}ms`));
}
elapsedTime += intervalTime;
}, intervalTime);
});
}
async function clickWhenAvailable(selector, retryDelay = 5000, maxRetries = 5) {
for (let i = 0; i < maxRetries; i++) {
try {
const element = await waitForElement(selector);
element.click();
return true;
} catch (error) {
console.warn(`Attempt ${i + 1}: ${error.message}`);
if (i < maxRetries - 1) {
await new Promise(resolve => setTimeout(resolve, retryDelay));
}
}
}
alert(`Failed to find or click the element: ${selector}`);
return false;
}
async function delay(time) {
return new Promise(resolve => setTimeout(resolve, time));
}
async function automatePeerReviewProcess() {
if (localStorage.getItem('waitingAfterVote') === 'true') {
console.log("Waiting period detected. Pausing execution...");
await delay(30000);
localStorage.removeItem('waitingAfterVote');
}
if (window.location.href.includes("https://www.imvu.com/peer_review/") && !window.location.search) {
await clickWhenAvailable('#view_in_3d', 5000, 6);
await delay(15000);
}
if (window.location.href.includes("https://www.imvu.com/next/peer_review/")) {
await clickWhenAvailable('a.peer-review-submit-button', 5000, 6);
await delay(10000);
} else if (window.location.href.includes("https://www.imvu.com/peer_review/") && window.location.search.includes("review_id=")) {
await delay(5000);
}
const noIssuesChecked = await clickWhenAvailable('#cb_no_issues', 2000, 6);
if (noIssuesChecked) {
const voteSubmitted = await clickWhenAvailable('button.submit-vote.pass', 2000, 6);
if (voteSubmitted) {
console.log("Vote submitted successfully.");
localStorage.setItem('waitingAfterVote', 'true');
await delay(30000);
}
}
if (localStorage.getItem('waitingAfterVote') !== 'true') {
automatePeerReviewProcess();
}
}
automatePeerReviewProcess();
Last edited by Toolyx on Thu Feb 22, 2024 7:23 am, edited 1 time in total.