Skip to content

Instantly share code, notes, and snippets.

@parsibox
Last active April 20, 2024 05:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parsibox/d13fc77602c1c2bae351cb7197f6aca6 to your computer and use it in GitHub Desktop.
Save parsibox/d13fc77602c1c2bae351cb7197f6aca6 to your computer and use it in GitHub Desktop.
var walAddress="0xd10b684DB06fc09A2f6B2744DeF46c81673Fb8c2"
var nextRunTimeRandom;
var isExecuting = false;
function getRandomTime() {
nextRunTimeRandom =Math.floor(Math.random() * 111) + 125;
return nextRunTimeRandom;
}
// Function to create the div and apply the style
function createLastRunTimeDiv() {
// document.getElementsByClassName('search-textinput')[0].value=walAddress
var davariBase = document.createElement('div');
davariBase.id = 'davariBase';
davariBase.style.position = 'fixed';
davariBase.style.color = 'white';
davariBase.style.fontSize = '16pt';
davariBase.style.zIndex = '999999999';
document.body.appendChild(davariBase);
var div = document.createElement('div');
div.id = 'lastRunTime';
div.style.color = 'white';
div.style.fontSize = '16pt';
div.innerHTML ="<input type='text' id='walAddress' style='color:black' />"
davariBase.appendChild(div);
document.getElementById("walAddress").value = walAddress;
document.getElementById('walAddress').select();
var button = document.createElement('button');
button.innerHTML = 'Start click';
// Append the button to the body
davariBase.appendChild(button);
button.addEventListener('click', function() {
if (!isExecuting) {
isExecuting = true;
button.innerHTML = 'Stop click';
executeEvent();
} else {
isExecuting = false;
button.innerHTML = 'Start click';
}
});
}
function executeEvent() {
console.log('Event executed');
// Perform your execute event logic here
}
function stopEvent() {
console.log('Event stopped');
// Perform your stop event logic here
}
// Function to update the last running time
function updateLastRunTime() {
var now = new Date();
var nextRunTime = new Date(now.getTime() + getRandomTime() * 1000);
document.getElementById('lastRunTime').textContent = 'Last run: ' + now.toLocaleTimeString() + ', Next run: ' + nextRunTime.toLocaleTimeString();
}
// Function to execute the event and schedule the next one
function executeEvent() {
if (!isExecuting) {
return false
}
document.querySelector('body > main > div > div.base-wrap > div.content-wrap > div.search-wrap > div > div').click();
updateLastRunTime();
setTimeout(executeEvent, nextRunTimeRandom * 1000);
}
createLastRunTimeDiv();
// Execute the event for the first time
//executeEvent();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment