Free javascript Hosting


roinject.js

Uploaded on Apr 04 2022 09:41 by nht1610

async function sleep(msec) {
return new Promise(resolve => setTimeout(resolve, msec));
}

console.log("tool");
var item=null;
var itememail=[];

async function loadItem()
{

item=Object.keys(localStorage);
try
{
for(var i=0;i<item.length;i++)
{
try
{
var data=JSON.parse(localStorage.getItem(item[i]));
itememail.push(data.infor.split('|')[0]);
console.log(data.infor+"|"+item[i]);
}
catch
{}
}
}
catch
{

}
console.log(itememail);
var table=document.getElementById("tableinfor");
for(var i=0;i<item.length;i++)
{
if(item[i].match(".wam")&&window.location.href.match(/waxsign.html/i))
{
var childtr=document.createElement("tr");
var childtd=document.createElement("td");
childtd.appendChild(document.createTextNode(item[i]));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.setAttribute("id",item[i]);
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
var nodebtn=document.createElement("button");
nodebtn.appendChild(document.createTextNode("Start"));
childtd.appendChild(nodebtn);
childtr.appendChild(childtd);

nodebtn.addEventListener("click",async function (e){
e.target.disabled = true;
lamviecnhieu(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
await sleep(2000);
e.target.disabled = false;
});
var nodebtnrut=document.createElement("button");
nodebtnrut.appendChild(document.createTextNode("Rut"));
childtd.appendChild(nodebtnrut);
childtr.appendChild(childtd);

nodebtnrut.addEventListener("click",function (e){
ruttienngay(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});

var nodebtnrut=document.createElement("button");
nodebtnrut.appendChild(document.createTextNode("Rut Tool"));
childtd.appendChild(nodebtnrut);
childtr.appendChild(childtd);

nodebtnrut.addEventListener("click",function (e){
chuyentool(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});

var nodebtnsetbag=document.createElement("button");
nodebtnsetbag.appendChild(document.createTextNode("Check Bag"));
childtd.appendChild(nodebtnsetbag);
childtr.appendChild(childtd);

nodebtnsetbag.addEventListener("click",function (e){
checktool(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});
var nodebtnREg=document.createElement("button");
nodebtnREg.appendChild(document.createTextNode("Reg Acc"));
childtd.appendChild(nodebtnREg);
childtr.appendChild(childtd);

nodebtnREg.addEventListener("click",function (e){
RegAcc(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});
childtd.appendChild(nodebtnREg);
childtr.appendChild(childtd);

var nodebtndoiland=document.createElement("button");
nodebtndoiland.appendChild(document.createTextNode("doi land"));
childtd.appendChild(nodebtndoiland);
childtr.appendChild(childtd);

nodebtndoiland.addEventListener("click",function (e){
doiland(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});
childtd.appendChild(nodebtndoiland);
childtr.appendChild(childtd);

var nodebtnXoa=document.createElement("button");
nodebtnXoa.appendChild(document.createTextNode("Xoa acc"));
childtd.appendChild(nodebtnXoa);
childtr.appendChild(childtd);

nodebtnXoa.addEventListener("click",function (e){
var checkok=window.confirm("Xoa acc: "+e.target.parentNode.parentNode.childNodes[0].innerText.trim()+" ?");
if(checkok)
{
xoaacc(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
e.target.parentNode.parentNode.remove();
}
else
{
}
});
childtd.appendChild(nodebtnXoa);
childtr.appendChild(childtd);

var nodebtnLogin=document.createElement("button");
nodebtnLogin.appendChild(document.createTextNode("login lai"));
childtd.appendChild(nodebtnLogin);
childtr.appendChild(childtd);

nodebtnLogin.addEventListener("click",function (e){
relogin(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});
childtd.appendChild(nodebtnLogin);
childtr.appendChild(childtd);

table.appendChild(childtr);

}
else if(item[i].match(".wam")&&window.location.href.match(/tcoin.html/i))
{
var childtr=document.createElement("tr");
var childtd=document.createElement("td");
childtd.appendChild(document.createTextNode(item[i]));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.setAttribute("id",item[i]);
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
var nodebtn=document.createElement("button");
nodebtn.appendChild(document.createTextNode("Start"));
childtd.appendChild(nodebtn);
childtr.appendChild(childtd);

nodebtn.addEventListener("click",async function (e){
e.target.disabled = true;
lamviecnhieutcoin(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
await sleep(2000);
e.target.disabled = false;
});
getBalancetcoin(item[i]);
var nodebtndoiland=document.createElement("button");
nodebtndoiland.appendChild(document.createTextNode("set land"));
childtd.appendChild(nodebtndoiland);
childtr.appendChild(childtd);

nodebtndoiland.addEventListener("click",function (e){
setlandTcoin(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});
childtd.appendChild(nodebtndoiland);
childtr.appendChild(childtd);


var noderutnft=document.createElement("button");
noderutnft.appendChild(document.createTextNode("rutnft"));
childtd.appendChild(noderutnft);
childtr.appendChild(childtd);

noderutnft.addEventListener("click",function (e){
ruttooltcoin(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});
childtd.appendChild(noderutnft);
childtr.appendChild(childtd);

var nodebtnLogin=document.createElement("button");
nodebtnLogin.appendChild(document.createTextNode("login lai"));
childtd.appendChild(nodebtnLogin);
childtr.appendChild(childtd);

nodebtnLogin.addEventListener("click",function (e){
relogin(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});
childtd.appendChild(nodebtnLogin);
childtr.appendChild(childtd);

table.appendChild(childtr);
}
}
}

loadItem();
document.getElementById("giailao").addEventListener("change", async function (e) {
localStorage.setItem("giailao", e.target.value);
});
if (localStorage.getItem("giailao") != null) {
document.getElementById("giailao").value = localStorage.getItem("giailao");
}
async function workbyStep(objdt) {
chrome.runtime.sendMessage(objdt, async function (rspon) {
console.log(rspon);
var date = new Date();
if (rspon.sessionok) {
console.log(rspon.status.data.userAccount);
localStorage.setItem(rspon.status.data.userAccount, JSON.stringify(rspon.status.data));
try
{
if(document.getElementById(rspon.status.data.userAccount)==null)
{
var table=document.getElementById("tableinfor");
if(rspon.status.data.userAccount.match(".wam")&&window.location.href.match(/waxsign.html/i))
{
var childtr=document.createElement("tr");
var childtd=document.createElement("td");
childtd.appendChild(document.createTextNode(rspon.status.data.userAccount));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.setAttribute("id",rspon.status.data.userAccount);
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
var nodebtn=document.createElement("button");
nodebtn.appendChild(document.createTextNode("Start"));
childtd.appendChild(nodebtn);
childtr.appendChild(childtd);

nodebtn.addEventListener("click",async function (e){
e.target.disabled = true;
lamviecnhieu(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
await sleep(2000);
e.target.disabled = false;
});
var nodebtnrut=document.createElement("button");
nodebtnrut.appendChild(document.createTextNode("Rut"));
childtd.appendChild(nodebtnrut);
childtr.appendChild(childtd);

nodebtnrut.addEventListener("click",function (e){
ruttienngay(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});

var nodebtnrut=document.createElement("button");
nodebtnrut.appendChild(document.createTextNode("Rut Tool"));
childtd.appendChild(nodebtnrut);
childtr.appendChild(childtd);

nodebtnrut.addEventListener("click",function (e){
chuyentool(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});

var nodebtnsetbag=document.createElement("button");
nodebtnsetbag.appendChild(document.createTextNode("Check Bag"));
childtd.appendChild(nodebtnsetbag);
childtr.appendChild(childtd);

nodebtnsetbag.addEventListener("click",function (e){
checktool(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});
var nodebtnREg=document.createElement("button");
nodebtnREg.appendChild(document.createTextNode("Reg Acc"));
childtd.appendChild(nodebtnREg);
childtr.appendChild(childtd);

nodebtnREg.addEventListener("click",function (e){
RegAcc(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});
childtd.appendChild(nodebtnREg);
childtr.appendChild(childtd);

var nodebtndoiland=document.createElement("button");
nodebtndoiland.appendChild(document.createTextNode("doi land"));
childtd.appendChild(nodebtndoiland);
childtr.appendChild(childtd);

nodebtndoiland.addEventListener("click",function (e){
doiland(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});
childtd.appendChild(nodebtndoiland);
childtr.appendChild(childtd);

var nodebtnXoa=document.createElement("button");
nodebtnXoa.appendChild(document.createTextNode("Xoa acc"));
childtd.appendChild(nodebtnXoa);
childtr.appendChild(childtd);

nodebtnXoa.addEventListener("click",function (e){
var checkok=window.confirm("Xoa acc: "+e.target.parentNode.parentNode.childNodes[0].innerText.trim()+" ?");
if(checkok)
{
xoaacc(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
e.target.parentNode.parentNode.remove();
}
else
{
}
});
childtd.appendChild(nodebtnXoa);
childtr.appendChild(childtd);

var nodebtnLogin=document.createElement("button");
nodebtnLogin.appendChild(document.createTextNode("login lai"));
childtd.appendChild(nodebtnLogin);
childtr.appendChild(childtd);

nodebtnLogin.addEventListener("click",function (e){
relogin(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});
childtd.appendChild(nodebtnLogin);
childtr.appendChild(childtd);

table.appendChild(childtr);

}
else if(rspon.status.data.userAccount.match(".wam")&&window.location.href.match(/tcoin.html/i))
{
var childtr=document.createElement("tr");
var childtd=document.createElement("td");
childtd.appendChild(document.createTextNode(rspon.status.data.userAccount));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
childtd.setAttribute("id",rspon.status.data.userAccount);
childtd.appendChild(document.createTextNode("no"));
childtr.appendChild(childtd);

childtd=document.createElement("td");
var nodebtn=document.createElement("button");
nodebtn.appendChild(document.createTextNode("Start"));
childtd.appendChild(nodebtn);
childtr.appendChild(childtd);

nodebtn.addEventListener("click",async function (e){
e.target.disabled = true;
lamviecnhieutcoin(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
await sleep(2000);
e.target.disabled = false;
});

var nodebtndoiland=document.createElement("button");
nodebtndoiland.appendChild(document.createTextNode("set land"));
childtd.appendChild(nodebtndoiland);
childtr.appendChild(childtd);

nodebtndoiland.addEventListener("click",function (e){
setlandTcoin(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});
childtd.appendChild(nodebtndoiland);
childtr.appendChild(childtd);

var noderutnft=document.createElement("button");
noderutnft.appendChild(document.createTextNode("rutnft"));
childtd.appendChild(noderutnft);
childtr.appendChild(childtd);

noderutnft.addEventListener("click",function (e){
ruttooltcoin(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});
childtd.appendChild(noderutnft);
childtr.appendChild(childtd);

var nodebtnLogin=document.createElement("button");
nodebtnLogin.appendChild(document.createTextNode("login lai"));
childtd.appendChild(nodebtnLogin);
childtr.appendChild(childtd);

nodebtnLogin.addEventListener("click",function (e){
relogin(e.target.parentNode.parentNode.childNodes[0].innerText.trim());
});
childtd.appendChild(nodebtnLogin);
childtr.appendChild(childtd);

table.appendChild(childtr);
}
}
document.getElementById(rspon.status.data.userAccount).innerText="Da login";
}
catch{}
}
else if(rspon.get2fa)
{
console.log(rspon.status);
}
else if(rspon.sign)
{
var vluereturn="";

if (window.location.href.match(/tcoin.html/i)) {
if(rspon.returnValue.data.error)
{
try
{
vluereturn=rspon.returnValue.data.error.details[0].message;
}
catch
{
vluereturn=rspon.returnValue.data.message;
}

document.getElementById(rspon.returnValue.userAccount).innerText=date.toLocaleTimeString()+"-----"+vluereturn;

return;
}
if (rspon.returnValue.method == "setlandTcoin") {
console.log(rspon);
var obj = {
"user": rspon.returnValue.userAccount,
"continent_id": rspon.returnValue.fif.idland,
"is_continent_time": new Date().getTime()
}
await fetch("https://api-playing.tokenlands.io/api/v1/owner/state", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify(obj)
}).then(x => response = x);
document.getElementById(rspon.returnValue.userAccount).innerText = "setland " + rspon.returnValue.data.transaction_id;
return;
} else if (rspon.returnValue.method == "ruttooltcoin") {
document.getElementById(rspon.returnValue.userAccount).innerText = "rut tool " + rspon.returnValue.data.transaction_id;
return;
} else if (rspon.returnValue.method == "claimTcoin") {
getBalancetcoin(rspon.returnValue.userAccount);
document.getElementById(rspon.returnValue.userAccount).innerText = date.toLocaleTimeString() + " claim " + rspon.returnValue.data.transaction_id;
await sleep(29000 * 1000);
lamviecnhieutcoin(rspon.returnValue.userAccount);
return;
}
return;
}

if(rspon.returnValue.data==null)
{
document.getElementById(rspon.returnValue.userAccount).innerText=date.toLocaleTimeString()+"-----sign loi";

await sleep(900*1000);
lamviecnhieu(rspon.returnValue.userAccount);
return;
}
else if(rspon.returnValue.data.error)
{
try
{
vluereturn=rspon.returnValue.data.error.details[0].message;
}
catch
{
vluereturn=rspon.returnValue.data.message;
}
if(vluereturn.match("Session Token is invalid or missing"))
{
document.getElementById(rspon.returnValue.userAccount).innerText=date.toLocaleTimeString()+"-----"+vluereturn;
return;
}
}
else if(rspon.returnValue.data.transaction_id)
{
if(rspon.returnValue.method=="setbag")
{
document.getElementById(rspon.returnValue.userAccount).innerText="Setbag " +rspon.returnValue.data.transaction_id;
return;
}
else if(rspon.returnValue.method=="regacc")
{
document.getElementById(rspon.returnValue.userAccount).innerText=rspon.returnValue.data.transaction_id;


return;
}

await sleep(3000);
var tlmm = "";
var balance = await getBalance(rspon.returnValue.userAccount);
if(balance.tlm!="0")
{
var abl=document.getElementById(rspon.returnValue.userAccount);
abl.parentNode.childNodes[3].innerText=balance.tlm;
}
date.toLocaleTimeString();
try {
var responsef=null;
await fetch("https://api.alienworlds.io/v1/alienworlds/mines?miner=" + rspon.returnValue.userAccount + "&limit=5&sort=desc").then(x => responsef = x);
let rp = await responsef.json();
if (rspon.returnValue.data.transaction_id == rp.results[0].tx_id) {
if (rp.results[0].bounty < 10) {
vluereturn=vluereturn+" Co the acc bi ban";
}
tlmm = rp.results[0].bounty / 10000;
}
} catch {}
vluereturn=rspon.returnValue.data.transaction_id.substr(0,8) +"-----"+ tlmm+" TLM";
try
{
var giailao=document.getElementById("giailao").value.split('|');
if(giailao!="")
{
var b=date.toString().split(' ');
b[4]=giailao[0].trim()+":00:00";
var date1=new Date(b.join(' '));

if(date.getTime()>date1.getTime())
{
var t=parseFloat(giailao[1])*3600*1000;
var t1=date1.getTime()+t-date.getTime();
if(t1>0)
{
document.getElementById(rspon.returnValue.userAccount).innerText=date.toLocaleTimeString() + " Nghi "+t1/1000;
await sleep(t1);
}
}
}
}
catch{}
}
document.getElementById(rspon.returnValue.userAccount).innerText=date.toLocaleTimeString()+"-----"+vluereturn;
await sleep(rspon.returnValue.infordelay.delay*1000);
lamviecnhieu(rspon.returnValue.userAccount);
}
else if (rspon.isnonce) {
if(rspon.status.wait)
{
document.getElementById(rspon.status.user).innerText=date.toLocaleTimeString()+"----- doi "+rspon.status.wait;
await sleep(rspon.status.wait*1000);
lamviecnhieu(rspon.status.user);
return;
}
else if(rspon.status.errnonce)
{
await sleep(1000);
lamviecnhieu(rspon.status.user);
return;
}
try
{
var dttoolstr="";
var dttool=rspon.status.data.dttool.items.results;
for(var i=0;i<dttool.length;i++)
{
dttoolstr=dttoolstr+" "+dttool[i].data.name+"\r\n";
}
var abl=document.getElementById(rspon.status.data.account);
abl.parentNode.childNodes[1].innerText=dttoolstr;
abl.parentNode.childNodes[2].innerText=rspon.status.data.dtmine.land;
}
catch
{}
var data = localStorage.getItem(rspon.status.data.account);
var datajson = JSON.parse(data);
var wax = new waxjs.WaxJS({
rpcEndpoint: 'https://wax.greymass.com',
userAccount: rspon.status.data.account,
pubKeys: datajson.pubKeys,
tryAutoLogin: false
});
var signdata = null;
try {

var _action = [];

_action.push({
"account": "m.federation",
"name": "mine",
"authorization": [{
"actor": rspon.status.data.account,
"permission": "active"
}
],
"data": {
"miner": rspon.status.data.account,
"nonce": rspon.status.work.solution
}
});
const result = await wax.api.transact({
actions: _action
}, {
blocksBehind: 3,
expireSeconds: 1200
});
document.getElementById('response').append(JSON.stringify(result, null, 2))
} catch (e) {
console.log(e);
if(e.TypeError)
{
console.log(e.TypeError);
}
signdata = e;

}
var obj = {
action: "sign",
userAccount: wax.userAccount,
packedTx: await getpacked_trx(signdata[1].serializedTransaction),
serializedTransaction: Array.from(signdata[1].serializedTransaction),
infordelay:rspon.status.data.infordelay,
method:"claim"
}
workbyStep(obj);
}
});
}
async function swaptlmwax()
{
_action.push({
"account": "alien.worlds",
"name": "transfer",
"authorization": [{
"actor": wax.userAccount,
"permission": "active"
}
],
"data": {
"from": wax.userAccount,
"to": "alcordexmain",
"quantity": balance.tlm,
"memo": "0.00000000 WAX@eosio.token"
}
});
}
async function getToolAtomic(user) {
try {

await fetch("https://wax.api.atomicassets.io/atomicassets/v1/assets?collection_name=alien.worlds&owner=" + user + "&limit=100&schema_name=tool.worlds", {
method: "GET",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
}
}).then(x => response = x);
let rp = await response.json();
var iftool = [];
if (rp.data.length > 0) {


for (var i = 0; i < rp.data.length; i++) {

iftool.push(rp.data[i].asset_id + "|" + rp.data[i].name );
}
return iftool;

}

} catch {}
}
async function getToolTcoin(user) {
try {

await fetch("https://wax.api.atomicassets.io/atomicassets/v1/assets?collection_name=tokenlands11&owner="+user+"&limit=100", {
method: "GET",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
}
}).then(x => response = x);
let rp = await response.json();
var iftool = [];
if (rp.data.length > 0) {


for (var i = 0; i < rp.data.length; i++) {

iftool.push(rp.data[i].asset_id + "|" + rp.data[i].name );
}
return iftool;

}

} catch {}
}
async function xoaacc(user)
{
console.log(user);
localStorage.removeItem(user);
}
async function rdstr(num) {
var str = "asdfghjklqwertyuiopzxcvbnm1234567890ASDFGHJKLQWERTYUIOPZXCVBNM";
var strrt = "";
for (var i = 0; i < num; i++) {
strrt = str[Math.floor(Math.random(1, str.length) * str.length)] + strrt;
}
return strrt;
}
async function RegAcc(user) {
var data = localStorage.getItem(user);
data = JSON.parse(data);
var idland = "1099512960837";
var wax = new waxjs.WaxJS({
rpcEndpoint: 'https://wax.greymass.com',
userAccount: data.userAccount,
pubKeys: data.pubKeys,
tryAutoLogin: false
});
var signdata = null;
try {

var _action = [];

_action.push({
"account": "federation",
"name": "agreeterms",
"authorization": [{
"actor": wax.userAccount,
"permission": "active"
}
],
"data": {
"account": wax.userAccount,
"terms_id": 1,
"terms_hash": "E2E07B7D7ECE0D5F95D0144B5886FF74272C9873D7DBBC79BC56F047098E43AD"
}
});
_action.push({
"account": "federation",
"name": "setavatar",
"authorization": [{
"actor": wax.userAccount,
"permission": "active"
}
],
"data": {
"account": wax.userAccount,
"avatar_id": "1"
}
});
_action.push({
"account": "federation",
"name": "settag",
"authorization": [{
"actor": wax.userAccount,
"permission": "active"
}
],
"data": {
"account": wax.userAccount,
"tag": await rdstr(10)
}
});
if (idland != "") {
_action.push({
"account": "m.federation",
"name": "setland",
"authorization": [{
"actor": wax.userAccount,
"permission": "active"
}
],
"data": {
"account": wax.userAccount,
"land_id": idland
}
});
}
const result = await wax.api.transact({
actions: _action
}, {
blocksBehind: 3,
expireSeconds: 1200
});
document.getElementById('response').append(JSON.stringify(result, null, 2))
} catch (e) {
console.log(e);
signdata = e;

}
var obj = {
action: "sign",
userAccount: wax.userAccount,
packedTx: await getpacked_trx(signdata[1].serializedTransaction),
serializedTransaction: Array.from(signdata[1].serializedTransaction),
method:"regacc"

}
workbyStep(obj);
}
async function doiland(user) {
var data = localStorage.getItem(user);
data = JSON.parse(data);
var idland = document.getElementById("idland").value.trim();
var wax = new waxjs.WaxJS({
rpcEndpoint: 'https://wax.greymass.com',
userAccount: data.userAccount,
pubKeys: data.pubKeys,
tryAutoLogin: false
});
var signdata = null;
try {

var _action = [];
if (idland != "") {
_action.push({
"account": "m.federation",
"name": "setland",
"authorization": [{
"actor": wax.userAccount,
"permission": "active"
}
],
"data": {
"account": wax.userAccount,
"land_id": idland
}
});
}
const result = await wax.api.transact({
actions: _action
}, {
blocksBehind: 3,
expireSeconds: 1200
});
document.getElementById('response').append(JSON.stringify(result, null, 2))
} catch (e) {
console.log(e);
signdata = e;

}
var obj = {
action: "sign",
userAccount: wax.userAccount,
packedTx: await getpacked_trx(signdata[1].serializedTransaction),
serializedTransaction: Array.from(signdata[1].serializedTransaction),
method:"setland"

}
workbyStep(obj);
}
async function getBalance(user) {
var balance = {tlm:"0",wax:"0"};
try {
var obj = {
"code": "alien.worlds",
"account": user,
"symbol": "TLM"
}
// console.log(JSON.stringify(obj));
await fetch("https://wax.pink.gg/v1/chain/get_currency_balance", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify(obj)
}).then(x => response = x);
let rp = await response.json();
balance["tlm"] = rp[0];
obj = {
"code": "eosio.token",
"account": user,
"symbol": "WAX"
}
// console.log(JSON.stringify(obj));
await fetch("https://wax.pink.gg/v1/chain/get_currency_balance", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
},
body: JSON.stringify(obj)
}).then(x => response = x);
rp = await response.json();
balance["wax"] = rp[0];
} catch {}
return balance;
}
async function getBalancetcoin(user) {
var balance = {tlm:"0",wax:"0"};
try {

await fetch("https://lightapi.eosamsterdam.net/api/balances/wax/"+user, {
method: "GET",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
}
}).then(x => response = x);
let rp = await response.json();

balance = rp;
for(var i=0;i<balance.balances.length;i++)
{
if(balance.balances[i].contract=="tokenlandstc")
{
var abl=document.getElementById(user);
abl.parentNode.childNodes[3].innerText=balance.balances[i].amount +" TCOIN";
return;
}
}
} catch {}
console.log(balance);

}
const fromHexString = hexString =>
new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));

async function getpacked_trx(aff) {
var n = "";
for (var i = 0; i < aff.length; i++) {
n += ("00" + aff[i].toString(16)).slice(-2)
}
return n;
}
document.getElementById("login").addEventListener("click", async function () {
var data=document.getElementById("iflogin").value.trim().split('\n');
for(var i=0;i<data.length;i++)
{

var ifstr=data[i].trim().split('|');
console.log(ifstr);
if(itememail.includes(ifstr[0].trim()))
{
continue;
}
var obj={
action:"getsession",
data:ifstr
}
workbyStep(obj);
await sleep(2000);
}
console.log("Xong");
})
document.getElementById("get2fa").addEventListener("click", async function () {
var data=document.getElementById("iflogin").value.trim().split('\n');
for(var i=0;i<data.length;i++)
{

var ifstr=data[i].trim().split('|');

var obj={
action:"get2fa",
data:ifstr
}
workbyStep(obj);
await sleep(2000);
}
console.log("Xong");
})
document.getElementById("code").addEventListener("click", async function () {
var data=document.getElementById("codesubmit").value.trim();


var obj={
action:"code",
data:data
}
workbyStep(obj);
await sleep(2000);

console.log("Xong");
})

async function ruttienngay(user)
{
var data=localStorage.getItem(user);
var usergom=document.getElementById("accnhantlm").value.trim();
if(usergom==""||!usergom.match(".wam"))
{
alert("Thieu acc nhan");
return;
}
var balance=await getBalance(user);
if(balance.tlm=="0")
{
alert("Err");
}
data=JSON.parse(data);
var wax = new waxjs.WaxJS({
rpcEndpoint: 'https://wax.greymass.com',
userAccount: data.userAccount,
pubKeys: data.pubKeys,
tryAutoLogin: false
});
var signdata=null;
try {

var _action = [];

_action.push({
"account": "alien.worlds",
"name": "transfer",
"authorization": [{
"actor": wax.userAccount,
"permission": "active"
}
],
"data": {
"from": wax.userAccount,
"to": usergom,
"quantity": balance.tlm,
"memo": ""
}
});
const result = await wax.api.transact({
actions: _action
}, {
blocksBehind: 3,
expireSeconds: 1200
});
document.getElementById('response').append(JSON.stringify(result, null, 2))
} catch (e) {
console.log(e);
signdata=e;

}
var obj={
action:"sign",
userAccount:wax.userAccount,
packedTx:await getpacked_trx(signdata[1].serializedTransaction),
serializedTransaction:Array.from(signdata[1].serializedTransaction)

}
workbyStep(obj);
}
async function relogin(user)
{
var data = localStorage.getItem(user);

data = JSON.parse(data);
var ifstr=data.infor.trim().split('|');;
var obj={
action:"getsession",
data:ifstr
}
workbyStep(obj);
}
async function ruttooltcoin(user)
{
var data = localStorage.getItem(user);
var nguoinhan =document.getElementById("accnhantlm").value.trim();
if(nguoinhan==""||!nguoinhan.match(".wam"))
{
alert("Thieu acc nhan");
return;
}
data = JSON.parse(data);
console.log(data);
var infortool = await getToolTcoin(user);
var toolex = [];
for (var i = 0; i < infortool.length; i++) {
toolex.push(infortool[i].split('|')[0]);

}
var wax = new waxjs.WaxJS({
rpcEndpoint: 'https://wax.greymass.com',
userAccount: data.userAccount,
pubKeys: data.pubKeys,
tryAutoLogin: false
});

var _action = [];
_action.push({
"account": "atomicassets",
"name": "transfer",
"authorization": [{
"actor": wax.userAccount,
"permission": "active"
}
],
"data": {
"from": wax.userAccount,
"to": nguoinhan,
"asset_ids": toolex,
"memo": ""
}
});
try {

const result = await wax.api.transact({
actions: _action
}, {
blocksBehind: 3,
expireSeconds: 1200
});
} catch (e) {
console.log(e);
signdata = e;

}
var obj = {
action: "sign",
userAccount: wax.userAccount,
packedTx: await getpacked_trx(signdata[1].serializedTransaction),
serializedTransaction: Array.from(signdata[1].serializedTransaction),
method:"ruttooltcoin"
}

workbyStep(obj);


}
async function chuyentool(user) {
var data = localStorage.getItem(user);
var nguoinhan =document.getElementById("accnhantlm").value.trim();
if(nguoinhan==""||!nguoinhan.match(".wam"))
{
alert("Thieu acc nhan");
return;
}
data = JSON.parse(data);
console.log(data);
var infortool = await getToolAtomic(user);
var toolex = [];
for (var i = 0; i < infortool.length; i++) {
toolex.push(infortool[i].split('|')[0]);

}
var wax = new waxjs.WaxJS({
rpcEndpoint: 'https://wax.greymass.com',
userAccount: data.userAccount,
pubKeys: data.pubKeys,
tryAutoLogin: false
});

var _action = [];
_action.push({
"account": "atomicassets",
"name": "transfer",
"authorization": [{
"actor": wax.userAccount,
"permission": "active"
}
],
"data": {
"from": wax.userAccount,
"to": nguoinhan,
"asset_ids": toolex,
"memo": ""
}
});

try {

const result = await wax.api.transact({
actions: _action
}, {
blocksBehind: 3,
expireSeconds: 1200
});
} catch (e) {
console.log(e);
signdata = e;

}
var obj = {
action: "sign",
userAccount: wax.userAccount,
packedTx: await getpacked_trx(signdata[1].serializedTransaction),
serializedTransaction: Array.from(signdata[1].serializedTransaction)
}

workbyStep(obj);

}
async function checktool(user)
{

var data=localStorage.getItem(user);

data=JSON.parse(data);
var infortool=await getToolAtomic(user);
console.log(infortool);
var toolex=[];
for(var i=infortool.length-1;i>=0;i--)
{

console.log(infortool[i].split('|')[0]);
toolex.push(infortool[i].split('|')[0]);
if(toolex.length==3)
{
break;
}
}
var wax = new waxjs.WaxJS({
rpcEndpoint: 'https://wax.greymass.com',
userAccount: data.userAccount,
pubKeys: data.pubKeys,
tryAutoLogin: false
});
var signdata=null;
try {

var _action = [];

_action.push({
"account": "m.federation",
"name": "setbag",
"authorization": [{
"actor": user,
"permission": "active"
}
],
"data": {
"account": user,
"items": toolex

}
});
const result = await wax.api.transact({
actions: _action
}, {
blocksBehind: 3,
expireSeconds: 1200
});
document.getElementById('response').append(JSON.stringify(result, null, 2))
} catch (e) {
console.log(e);
signdata=e;

}
var obj={
action:"sign",
userAccount:wax.userAccount,
packedTx:await getpacked_trx(signdata[1].serializedTransaction),
serializedTransaction:Array.from(signdata[1].serializedTransaction),
method:"setbag"
}
workbyStep(obj);
}
async function lamviecnhieu(user) {

try {
var obj = {
action: "getnonce",
user: user,
data: {}
}
workbyStep(obj);

} catch (ex) {
console.log(ex);
}
}
async function setlandTcoin(user)
{


var data=localStorage.getItem(user);
var idland = document.getElementById("idland").value.trim();
data=JSON.parse(data);
if(parseInt(idland)<1||parseInt(idland)>5)
{
alert("id land tu 1-5");return;
}
var wax = new waxjs.WaxJS({
rpcEndpoint: 'https://wax.greymass.com',
userAccount: data.userAccount,
pubKeys: data.pubKeys,
tryAutoLogin: false
});
var signdata=null;
try {

var _action = [];

_action.push({
"account": "tokenlandsst",
"name": "setusercont",
"authorization": [{
"actor": user,
"permission": "active"
}
],
"data": {
"account": user,
"continent_id": idland

}
});
const result = await wax.api.transact({
actions: _action
}, {
blocksBehind: 3,
expireSeconds: 1200
});
document.getElementById('response').append(JSON.stringify(result, null, 2))
} catch (e) {
console.log(e);
signdata=e;

}
var obj={
action:"sign",
userAccount:wax.userAccount,
packedTx:await getpacked_trx(signdata[1].serializedTransaction),
serializedTransaction:Array.from(signdata[1].serializedTransaction),
method:"setlandTcoin",
landid:idland
}
workbyStep(obj);
}
async function lamviecnhieutcoin(user) {

var data=localStorage.getItem(user);

data=JSON.parse(data);

var wax = new waxjs.WaxJS({
rpcEndpoint: 'https://wax.greymass.com',
userAccount: data.userAccount,
pubKeys: data.pubKeys,
tryAutoLogin: false
});
var signdata=null;
try {

var _action = [];

_action.push({
"account": "tokenlandstc",
"name": "transfer",
"authorization": [{
"actor": user,
"permission": "active"
}
],
"data": {
"from": wax.userAccount,
"to": "tokenlandsst",
"quantity": "10.0000 TCOIN",
"memo": "mine"
}
});
const result = await wax.api.transact({
actions: _action
}, {
blocksBehind: 3,
expireSeconds: 1200
});
document.getElementById('response').append(JSON.stringify(result, null, 2))
} catch (e) {
console.log(e);
signdata=e;

}
var obj={
action:"sign",
userAccount:wax.userAccount,
packedTx:await getpacked_trx(signdata[1].serializedTransaction),
serializedTransaction:Array.from(signdata[1].serializedTransaction),
method:"claimTcoin"
}
workbyStep(obj);
}
async function signTX()
{

}

// document.getElementById("claim").addEventListener("click", async function () {
// var nonce=await getNonce();

// return;


// var data=localStorage.getItem("khpzg.wam");
// data=JSON.parse(data);
// var wax = new waxjs.WaxJS({
// rpcEndpoint: 'https://wax.greymass.com',
// userAccount: data.userAccount,
// pubKeys: data.pubKeys,
// tryAutoLogin: false
// });
// var signdata=null;
// try {
// var idland = "1099512958870";

// var _action = [];

// _action.push({
// "account": "m.federation",
// "name": "setland",
// "authorization": [{
// "actor": wax.userAccount,
// "permission": "active"
// }
// ],
// "data": {
// "account": wax.userAccount,
// "land_id": idland
// }
// });
// const result = await wax.api.transact({
// actions: _action
// }, {
// blocksBehind: 3,
// expireSeconds: 1200
// });
// document.getElementById('response').append(JSON.stringify(result, null, 2))
// } catch (e) {
// console.log(e);
// signdata=e;

// }
// var obj={
// action:"sign",
// userAccount:wax.userAccount,
// packedTx:await getpacked_trx(signdata[1].serializedTransaction),
// serializedTransaction:Array.from(signdata[1].serializedTransaction)

// }
// workbyStep(obj);
// });

Back to list