pyblock/PyBLOCK-Widget.scriptable

73 lines
2.7 KiB
Text
Raw Permalink Normal View History

2024-07-23 01:16:02 +02:00
// PyBLØCK Widget by PyBLØCK-Crew
let req = new Request("https://mempool.space/api/blocks/tip/height");
let blockHeight = await req.loadString();
let count = new Request('https://blockchain.info/q/unconfirmedcount');
let tx = await count.loadString();
let make = new Request('https://mempool.space/api/v1/fees/recommended');
let json = await make.loadJSON();
fast = json.fastestFee.toString();
halfHour = json.halfHourFee.toString();
hour = json.hourFee.toString();
let call = new Request('https://blockchain.info/q/totalbc');
let supply = await call.loadString();
let get = new Request('https://blockchain.info/tobtc?currency=USD&value=1');
let MoscowTime = await get.loadString();
let prin = new Request('https://blockchain.info/q/24hrprice');
let Price = await prin.loadString();
let widget = await createWidget();
if (config.runsInWidget)
{
Script.setWidget(widget);
}
else
{
widget.presentLarge();
}
Script.complete();
async function createWidget()
{
let listwidget = new ListWidget();
listwidget.backgroundColor = new Color("#000000");
let nextRefresh = Date.now() + 1000*10
listwidget.refreshAfterDate = new Date(nextRefresh)
let sns = new Request('https://raw.githubusercontent.com/curly60e/pyblock/master/pybitblock/resources/images/Logo.PNG');
let pyp = await sns.loadImage();
let tt = listwidget.addImage(pyp).centerAlignImage()
let heading = listwidget.addText(blockHeight);
heading.centerAlignText();
heading.font = Font.boldSystemFont(70);
heading.textColor = new Color("#0aff17");
let txs = listwidget.addText("▁▂▃▄▅▆▇ " + tx + " ▇▆▅▄▃▂▁");
txs.centerAlignText();
txs.font = Font.boldSystemFont(13);
txs.textColor = new Color("#FFFFFF");
let wdgDesc = listwidget.addText("🟥 🟨 🟩");
let mem = listwidget.addText(fast + " " + halfHour + " " + hour);
wdgDesc.centerAlignText();
mem.centerAlignText();
wdgDesc.font = Font.boldSystemFont(10);
if(fast < 10)
mem.font = Font.boldSystemFont(30);
else if(fast < 100)
mem.font = Font.boldSystemFont(30);
else
mem.font = Font.boldSystemFont(30);
wdgDesc.textColor = new Color("#EEEEEE");
mem.textColor = new Color("#0aff17");
let pr = listwidget.addText(Price + " $ = 1 ₿itcoin");
pr.centerAlignText();
pr.font = Font.boldSystemFont(13);
pr.textColor = new Color("#EEEEEE")
let ms = listwidget.addText(MoscowTime +" Șats = 1 $");
ms.centerAlignText();
ms.font = Font.boldSystemFont(22);
ms.textColor = new Color("#0aff17")
let coin = listwidget.addText(supply + " Supply");
coin.centerAlignText();
coin.font = Font.boldSystemFont(13);
coin.textColor = new Color("#EEEEEE")
let req = new Request('https://pbs.twimg.com/media/E3IikexWYAQfqY2.png');
let SN = await req.loadImage();
let gn = listwidget.addImage(SN).centerAlignImage()
return listwidget;
}