Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FreePhoenix888/f9238ebfbdc86616e159abb59a626ce4 to your computer and use it in GitHub Desktop.
Save FreePhoenix888/f9238ebfbdc86616e159abb59a626ce4 to your computer and use it in GitHub Desktop.
Find "Get Community Points" button and click with interval
findGetCommunityPointsButtonAndClickWithInterval();
/**
* Finds the get community points button
*/
function findGetCommunityPointsButton() {
const communityPointsContainerElement = document.body.querySelector(
".community-points-summary"
);
console.log({ communityPointsContainerElement });
if (!communityPointsContainerElement) {
throw new Error(
"No container found, the script is outdated because the class name has changed"
);
}
const getCommunityPointsButtonElement =
communityPointsContainerElement.querySelectorAll("button")[1];
console.log({ getCommunityPointsButtonElement });
return getCommunityPointsButtonElement;
}
/**
* Finds the get community points button and clicks it
*/
function findGetCommunityPointsButtonAndClick() {
const getCommunityPointsButtonElement = findGetCommunityPointsButton();
if (getCommunityPointsButtonElement) {
getCommunityPointsButtonElement.click();
} else {
console.log("No button found");
}
}
/**
* Finds the get community points button and clicks it every {@link intervalInMs} milliseconds
* @example
* ```
* findGetCommunityPointsButtonAndClickWithInterval()
* ```
*/
function findGetCommunityPointsButtonAndClickWithInterval(
options = { intervalInMs: 30 * 1000 }
) {
const { intervalInMs } = options;
findGetCommunityPointsButtonAndClick();
setInterval(findGetCommunityPointsButtonAndClick, intervalInMs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment