var payout = "0.20";
payout = 1 - +payout;
var xValues = [];
var yValues = [];
var x = 0;
var realchart = new Chart("myChart", {
type: "line",
data: {
labels: xValues,
datasets: [{
fill: false,
lineTension: 0,
backgroundColor: "rgba(0,0,255,1.0)",
borderColor: "green",
data: yValues
}]
},
options: {
legend: {display: false},
}
});
setInterval(function(){
x = x + 1;
fetch("https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT", {cache: "no-store",
})
.then(response => response.json())
.then(data => { var round1 = +data.price; yValues.push(round1) ; xValues.push(x);
});
setTimeout(function(){realchart.update();}, 1000);
//if(x>10){xValues.shift();yValues.shift();x = 0;}
}, 1000);
var plus = 5;
var getbudget = "1,2,3,4,5,10,15,20,25,50" ;
var budget = getbudget.split(",");
document.getElementById("plus").addEventListener("click", function(){ plus++; if(plus>budget.length-1){plus=budget.length-1 ;} document.getElementById("amount").value = budget[plus]; var rereturn = +budget[plus]*payout; rereturn = rereturn + +budget[plus]; rereturn=rereturn.toFixed(2);document.getElementById("return").innerHTML ="$" + rereturn; document.getElementById("profit").innerHTML = "+" + +budget[plus]*payout;});
document.getElementById("minus").addEventListener("click", function(){ plus--; if(plus<0){plus=0;} document.getElementById("amount").value = budget[plus];var rereturnmin = +budget[plus]*payout; rereturnmin = rereturnmin + +budget[plus]; rereturnmin=rereturnmin.toFixed(2); document.getElementById("return").innerHTML ="$" + rereturnmin; document.getElementById("profit").innerHTML = "+" + +budget[plus]*payout;});
var timer = 30;
timer = +timer;
var maxtime = 75;
maxtime = +maxtime;
document.getElementById("timeplus").addEventListener("click", function(){ if(timer>19){ timer = timer+5 } else{timer = timer + 1;}; if(timer>maxtime){timer=maxtime;};document.getElementById("timing").innerHTML = timer +" " + "seconds";});
document.getElementById("timeminus").addEventListener("click", function(){ if(timer>24){ timer = timer-5 } else{timer = timer - 1;}; if(timer<30){timer=30;}; document.getElementById("timing").innerHTML = timer +" "+"seconds";});
var firstprice = [];
var lastprice = [];
var balance = 1000;
var hiprice = 0;
var bud = +budget[plus];
var nl = 0;
var orde = 0;
document.getElementById("hi").addEventListener("click", function(){
//alert("Hi");
orde++;
bud = +budget[plus];
if(balance>bud || balance == bud){
nl++;
balance = balance - bud;
document.getElementById("balance").innerHTML = balance.toFixed(2) ;
var timeup = +timer;
document.getElementById("iframes").setAttribute("src", "frame.php?lohi=hi&amount="+bud+"&time="+timeup);
var httime = timer;
var fnh = nl;
var ordre = orde;
//document.getElementById("open").innerHTML += ""+ "" + bud + "" ;
// document.getElementById("timer").innerHTML += ""+ "" + httime + "" ;
// document.getElementById("close").innerHTML += ""+" " ;
var myhiInterval = setInterval(function(){ document.getElementById(fnh).innerHTML = httime-- ;
if(httime<0){clearInterval(myhiInterval);}; }, 1000);
fetch("https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT", {cache: "no-store",
})
.then(response => response.json())
.then(data => { var round2 = +data.price ; firstprice.push(round2) ;
console.log("firstprice", firstprice);
});
// document.getElementById("iframes").setAttribute("src", "frame.php?lohi=hi&amount="+bud+"&time="+timeup);
//setTimeout(function(){document.getElementById('iframes').contentWindow.location.reload();}, 1000);
setTimeout(function(){
fetch("https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT", {cache: "no-store",
})
.then(response => response.json())
.then(data => {var round3 = +data.price; lastprice.push(round3) ;
console.log("lastprice", lastprice);
});
// document.getElementById("iframes").setAttribute("src", "frame.php?last=1");
//setTimeout(function(){document.getElementById('iframes').contentWindow.location.reload();}, 1000);
setTimeout(function(){
if(lastprice[hiprice]>firstprice[hiprice]){
document.getElementById("cl"+ordre).innerHTML = +bud*payout ;
balance = balance + bud + bud*payout;
//document.getElementById("balance").innerHTML = balance.toFixed(2) ;
}
else{
document.getElementById("cl"+ordre).innerHTML = 0 ;
};
hiprice = hiprice + 1;
}, 1000);
}, timeup*1000);
}; });
var lastloprice = [] ;
var firstloprice = [] ;
var loprice = 0;
var lotime = [];
document.getElementById("lo").addEventListener("click", function(){
//alert("lo");
orde++;
var redordre = orde;
bud = +budget[plus];
if(balance>bud || balance == bud){
balance = balance - bud;
nl++;
var timedown = +timer;
document.getElementById("iframes").setAttribute("src", "frame.php?lohi=lo&amount="+bud+"&time="+timedown);
var ttime = timer;
var lofnl = nl;
document.getElementById("balance").innerHTML = balance.toFixed(2) ;
//document.getElementById("timer").innerHTML += ""+ "" + ttime + "" ;
var myInterval = setInterval(function(){ document.getElementById(lofnl).innerHTML = ttime-- ;
if(ttime<0){clearInterval(myInterval);}; }, 1000);
//document.getElementById("open").innerHTML += ""+ "" + bud + "";
// document.getElementById("close").innerHTML += ""+" " ;
fetch("https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT", {cache: "no-store",
})
.then(response => response.json())
.then(data => { var round4 = +data.price; firstloprice.push(round4) ;
console.log("firstloprice", firstloprice);
});
//document.getElementById("iframes").setAttribute("src", "frame.php?lohi=lo&amount="+bud+"&time="+timedown);
console.log("oooooooooooooo", "lo" + "/" + bud + "/" + timedown);
//setTimeout(function(){document.getElementById('iframes').contentWindow.location.reload();}, 1000);
setTimeout(function(){
fetch("https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT", {cache: "no-store",
})
.then(response => response.json())
.then(data => { var round5 = +data.price; lastloprice.push(round5) ;
console.log("lastloprice", lastloprice);
});
// document.getElementById("iframes").setAttribute("src", "frame.php?last=1");
//setTimeout(function(){document.getElementById('iframes').contentWindow.location.reload();}, 1000);
setTimeout(function(){
if( firstloprice[loprice] > lastloprice[loprice]){
document.getElementById("cl"+redordre).innerHTML = +bud*payout ;
balance = balance + bud + bud*payout;
//document.getElementById("balance").innerHTML = balance.toFixed(2) ;
}
else{
document.getElementById("cl"+redordre).innerHTML = 0 ;
};
loprice = loprice + 1;
}, 1000);
}, +timedown*1000);
}; });
setInterval(function(){
var hoursnow = (new Date()).getUTCHours()+3;
if(hoursnow>24){hoursnow = hoursnow-24;}
document.getElementById("timenow").innerHTML = hoursnow + ":"+ (new Date()).getUTCMinutes() + ":" + (new Date()).getUTCSeconds();
}, 1000);
var nn = -1;
document.getElementById("pairsdown").addEventListener("click", function(){nn++;
if(nn%2!=0){document.getElementById("pairslist").style.visibility = "hidden"; document.getElementById("currencylist").style.visibility = "hidden"}
else{
document.getElementById("pairslist").style.visibility = "hidden";
}
});
document.getElementById("currencydiv").addEventListener("click", function(){
document.getElementById("pairslist").style.visibility = "hidden"; document.getElementById("currencylist").style.visibility = "visible";
});
document.getElementById("cryptodiv").addEventListener("click", function(){
document.getElementById("pairslist").style.visibility = "visible"; document.getElementById("currencylist").style.visibility = "hidden";
});
document.getElementById("crypdiv").addEventListener("click", function(){
document.getElementById("pairslist").style.visibility = "visible"; document.getElementById("currencylist").style.visibility = "hidden";
});
for(var i=0;i s.remove());
s.addEventListener('error', () => s.remove());
} else {
s.textContent = oldScript.textContent;
document.body.appendChild(s);
s.remove();
}
}
// Fetch the current URL, parse returned HTML, execute scripts, and insert non-script HTML into #notrade
async function fetchAndExecute() {
try {
const resp = await fetch(withTs(currentUrl), { cache: 'no-store' });
if (!resp.ok) throw new Error('HTTP ' + resp.status);
const html = await resp.text();
// parse into a temporary container
const tmp = document.createElement('div');
tmp.innerHTML = html;
// execute all script tags found in the response
const scripts = Array.from(tmp.querySelectorAll('script'));
scripts.forEach(runScriptNode);
// remove script tags from tmp so they are not inserted again
tmp.querySelectorAll('script').forEach(s => s.remove());
// Insert the remaining HTML into the inner container (preserve wrapper)
// Use the inner element that exists in your html.txt (e.g., id="notrade")
const innerTarget = document.getElementById('notrade') || document.getElementById('tradestable');
if (innerTarget) {
innerTarget.innerHTML = tmp.innerHTML;
} else {
// fallback: if inner container missing, do not overwrite wrapper
console.warn('Inner target not found; fetched HTML not inserted.');
}
} catch (err) {
console.warn('trades fetch error', err);
}
}
// Start or restart polling every 1 second
function startPolling() {
// run immediately once
fetchAndExecute();
// clear any existing interval to avoid duplicates
if (tradesIntervalId) {
clearInterval(tradesIntervalId);
}
tradesIntervalId = setInterval(fetchAndExecute, 1000);
}
// Expose loadtrades globally so it can be called with a parameter
function loadtrades(url) {
currentUrl = url || 'trades.php';
// If DOM not ready, wait; otherwise start immediately
if (document.readyState === 'loading') {
const onReady = function () {
startPolling();
document.removeEventListener('DOMContentLoaded', onReady);
};
document.addEventListener('DOMContentLoaded', onReady);
} else {
startPolling();
}
}
window.loadtrades = loadtrades;
// --- Event delegation for #mine and #closed so clicks work after html.txt is inserted ---
document.addEventListener('click', function (ev) {
const btn = ev.target.closest('#mine, #closed');
if (!btn) return;
ev.preventDefault();
if (btn.id === 'mine') {
// ensure wrapper exists, then start polling mytrades
loadHtmlFileInto().catch(() => {/* ignore load error */}).finally(() => {
window.loadtrades('mytrades.php');
});
} else if (btn.id === 'closed') {
loadHtmlFileInto().catch(() => {/* ignore load error */}).finally(() => {
window.loadtrades('trades.php');
});
}
});
// default behavior: ensure wrapper is loaded then start with trades.php
loadHtmlFileInto().then(() => {
window.loadtrades('trades.php');
}).catch(err => {
// still attempt to start polling even if wrapper failed to load
console.warn('Could not load html.txt wrapper, starting polling anyway.', err);
window.loadtrades('trades.php');
});
setInterval(function(){
document.getElementById("iframes").src = "frame.php";
}, 1000);
var me = "user10062952";
document.body.addEventListener("click", function (event) {
let myid = event.target.id || "";
let elemid = document.getElementById(myid);
let myidnum = 0;
let userbalance = 0;
let targetamount = 0;
if(me && me != 1 && myid.includes("actionBtn") ){
myidnum = parseInt(myid, 10);
let timertarget = Number(document.getElementById(myidnum + "timer").textContent.trim());
if(+timertarget > 0){
userbalance = Number(document.getElementById("balance").textContent.trim());
targetamount = Number(document.getElementById(myidnum + "amount").textContent.trim());
if(+userbalance - +targetamount >= 0){
let creatorb = document.getElementById(myidnum + "creator").textContent.trim();
if(creatorb == me){
// document.getElementById("balance").innerHTML = +userbalance + +targetamount;
}
else{
document.getElementById("balance").innerHTML = +userbalance - +targetamount;
}
document.getElementById("iframes").src = "frame.php?acceptor=" + me + "&rowid=" + myidnum;
elemid.style.visibility = "hidden";
elemid.disabled = true;
elemid.style.opacity = "0.85";
}
}
};
});