Skip to content

Instantly share code, notes, and snippets.

@meddokss
Last active May 19, 2021 10:59
Show Gist options
  • Save meddokss/46c8c4b79340a9cc39e77d6ae0b18cd3 to your computer and use it in GitHub Desktop.
Save meddokss/46c8c4b79340a9cc39e77d6ae0b18cd3 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Add items to RPLANET
// @namespace Meddoks
// @version 2.0.0
// @description Add items to RPLANET
// @author Meddoks
// @match https://rplanet.io/stake/alienworlds
// @grant none
// ==/UserScript==
(async function() {
if (window.console.everything === undefined) {
window.console.everything = '';
window.console.defaultLog = window.console.log.bind(window.console);
window.console.log = function() {
window.console.everything = Array.from(arguments)[1];
window.console.defaultLog.apply(window.console, arguments);
};
}
let delay = async(ms) => {
return new Promise((res) => setTimeout(() => {
res(true);
}, ms));
};
let staking = false;
let counter = 0;
let disableButton = (type, isDisabled) => {
let btn = document.getElementById(type);
btn.disabled = isDisabled;
btn.style.background = isDisabled ? 'grey' : 'red';
};
let start = async function() {
let allItems = document.querySelectorAll('button.Button_stake_button__3iq5g').length - 1;
let items = parseInt(document.getElementById('nft_numbers').value);
items = items ? items : allItems;
staking = true;
disableButton('btn_stop', !staking);
disableButton('btn_start', staking);
console.log(`%c[BOT] Bot start. This time you try to add ${items} cards`, 'color:white; background: green');
while (counter <= items && staking) {
await delay(1000);
let stake = document.querySelector('button.Button_stake_button__3iq5g');
stake.click();
let w = true;
while (w) {
await delay(1000);
if (window.console.everything && window.console.everything.includes('next_key')) {
w = false;
counter = counter + 1;
console.log(`%c[BOT] NFT #${counter} added`, 'color:white; background: purple');
}
}
}
await stop();
};
let stop = async function() {
staking = false;
disableButton('btn_stop', !staking);
disableButton('btn_start', staking);
console.log(`%c[BOT] Work end. This time you added ${counter} cards`, 'color:white; background: green');
counter = 0;
};
window.ADD_ITEMS_TO_R_PLANET = async function() {
await delay(2000);
let inputItemsCount = document.createElement('input');
inputItemsCount.type = 'number';
inputItemsCount.name = 'add_items';
inputItemsCount.id = 'nft_numbers';
inputItemsCount.min = '0';
inputItemsCount.max = '100';
inputItemsCount.value = '0';
inputItemsCount.style.cssText += 'z-index: 1000; margin: 20px; padding: 5px 5px; color: white; background: red;';
let buttonStop = document.createElement('button');
buttonStop.addEventListener('click', () => { staking = false }, false);
buttonStop.innerHTML = 'STOP';
buttonStop.setAttribute('id', 'btn_stop');
buttonStop.style.cssText += 'z-index: 1000; margin: 20px; padding: 5px 5px; background: red; color: white';
let buttonStart = document.createElement('button');
buttonStart.addEventListener('click', start, false);
buttonStart.innerHTML = 'START';
buttonStart.setAttribute('id', 'btn_start');
buttonStart.style.cssText += 'z-index: 1000; margin: 20px; padding: 5px 5px; background: green; color: white';
document.body.appendChild(buttonStart);
document.body.appendChild(inputItemsCount);
document.body.appendChild(buttonStop);
};
await window.ADD_ITEMS_TO_R_PLANET();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment