Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

// ==UserScript==

// @name Cunhagem
// @description Developed by Mario, updated by Thiago and Rodrigo
// @author Rodrigo
// @version 0.3.0
// @require https://code.jquery.com/jquery-3.2.1.min.js
// @include https://*/game.php?*screen=snob*
// ==/UserScript==
const storageTimeOut = parseInt(localStorage.getItem('timeOut'));
const storageActive = localStorage.getItem('coin');

let timeOut;
if (isNaN(storageTimeOut)) {
timeOut = 10000;
localStorage.setItem('timeOut', JSON.stringify(timeOut));
} else {
timeOut = storageTimeOut*1000;
}

let coin;
if(storageActive == null) coin = false;
else coin = storageActive;

inputHtml();

if(coin == 'true'){
setTimeout(()=>{
const jquery = $('#coin_mint_fill_max');
const number = jquery[0];
const button = jquery.siblings()[1];
const inactive = $('span.inactive').length == 0;
if(inactive) {
number.click();
setTimeout(()=>button.click());
} else {
console.log('recursos indisponiveis');
document.getElementById('delayTime').innerHTML = 'recursos
indisponiveis';
setTimeout(()=>pageReload(),2000);
}
},timeOut);
}

function pageReload() {
window.location.reload();
}

function inputHtml() {
const isActive = coin == 'true' ? 'Ligado' : 'Desligado';

const htmlValue =`
<style>
#activeLabel{color: red; font-size: 25px;}
</style>
<tr>
<td id='setTimeElement'>
Tempo para recarregar (delay time) in seconds
</td>
<td>
<input id='delayInput' value='${timeOut/1000}' style='width:50px'>
<a id="delayButton" class="btn">OK</a>
</td>
</tr>
<tr>
<td>
Proxima auto recarga em:
</td>
<td>
<strong id="delayTime">${timeOut/1000} segundos</strong>
</td>
</tr>
<tr>
<td>
Status: <strong id='activeLabel'>${isActive}</strong>
</td>
<td>
<a id="isActiveButton" class="btn">${coin != 'true' ? 'Ligar' :
'Desligar' }</a>
</td>
</tr>
`;

document.getElementsByClassName('vis')
[3].children[0].children[9].insertAdjacentHTML('afterend', htmlValue);

const delayButton = document.getElementById('delayButton');


delayButton.onclick =()=>{
const value = document.getElementById('delayInput').value;
if(value == 0) return;
localStorage.setItem("timeOut", JSON.stringify(parseInt(value)));
timeOut = value * 60000;
document.getElementById('delayTime').innerHTML = value + ' segundos';
pageReload();
};

const isActiveButton = document.getElementById('isActiveButton');


isActiveButton.onclick = () =>{
if(coin == 'true'){
localStorage.setItem('coin', false);
} else {
localStorage.setItem('coin', true);
}
pageReload();
}
}

You might also like