forked from curly60e/pyblock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PyBLΓCK Widget.scriptable
126 lines (87 loc) Β· 3.33 KB
/
PyBLΓCK Widget.scriptable
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Made 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://bitcoinexplorer.org/api/mempool/summary');
let tx = await count.loadJSON();
number = tx.size.toString();
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://bitcoinexplorer.org/api/blockchain/coins');
let supply = await call.loadJSON();
coins = supply.supply.toString();
let get = new Request('https://bitcoinexplorer.org/api/price/sats');
let MoscowTime = await get.loadJSON();
psats = MoscowTime.usd.toString();
let prin = new Request('https://bitcoinexplorer.org/api/price');
let Price = await prin.loadJSON();
pusd = Price.usd.toString();
let widget = await createWidget();
// Check where the script is running
if (config.runsInWidget)
{
// Runs inside a widget so add it to the homescreen widget
Script.setWidget(widget);
}
else
{
// Show the medium widget inside the app
widget.presentLarge();
}
Script.complete();
async function createWidget()
{
// Create new empty ListWidget instance
let listwidget = new ListWidget();
// Set new background color
listwidget.backgroundColor = new Color("#000000");
// add 10 second to now
let nextRefresh = Date.now() + 1000*10
listwidget.refreshAfterDate = new Date(nextRefresh)
// Add widget heading
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("βββββ
ββ " + number + " βββ
ββββ");
txs.centerAlignText();
txs.font = Font.boldSystemFont(13);
txs.textColor = new Color("#FFFFFF");
let wdgDesc = listwidget.addText("π₯ π¨ π©");
// Add widget heading
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(pusd + " $ = 1 βΏitcoin");
pr.centerAlignText();
pr.font = Font.boldSystemFont(13);
pr.textColor = new Color("#EEEEEE")
let ms = listwidget.addText(psats + " δΈ° = 1 $");
ms.centerAlignText();
ms.font = Font.boldSystemFont(22);
ms.textColor = new Color("#0aff17")
let coin = listwidget.addText(coins + " 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();
// Add widget heading
let gn = listwidget.addImage(SN).centerAlignImage()
// Return the created widget
return listwidget;
}