Repository navigation
Expand file tree
/
Copy pathptu.js
More file actions
97 lines (81 loc) · 2.81 KB
/
Copy pathptu.js
File metadata and controls
97 lines (81 loc) · 2.81 KB
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
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: cyan; icon-glyph: magic;
//Script for getting PTU Status from robertspaceindustries.com
let live,ptu
let url = "https://robertsspaceindustries.com/roadmap/progress-tracker/teams"
let view = new WebView()
await view.loadURL(url)
sleep(10000)
let html = await view.getHTML()
//console.log(html.length)
//console.log(html)
let regex_live = /Live Version\: (.*?) /
let regex_ptu = /PTU Version\: (.*?)\</
let version_live = html.match(regex_live)
live = version_live[1]
let version_ptu = html.match(regex_ptu)
ptu = version_ptu[1]
console.log(live)
console.log(ptu)
let req = new Request("https://www.dpgaming.de/images/DPG.ico?1625848083")
let image = await req.loadImage()
let widget = createWidget();
widget.backgroundImage = image
if (!config.runsInWidget) {
await widget.presentSmall()
}
Script.setWidget(widget);
Script.complete();
function createWidget() {
const w = new ListWidget()
let row = w.addStack()
// Ueberschrift
let texti = row.addText("SC Version")
texti.font = Font.boldSystemFont(18)
texti.textColor = Color.red()
texti.shadowColor = Color.black()
texti.shadowOffset = new Point(1,1)
texti.shadowRadius = 1
texti.centerAlignText()
w.addSpacer(3)
row = w.addStack()
texti = row.addText("Live:")
texti.font = Font.boldSystemFont(18)
texti.textColor = Color.red()
texti.shadowColor = Color.black()
texti.shadowOffset = new Point(1,1)
texti.shadowRadius = 1
row.addSpacer()
texti = row.addText(live)
texti.font = Font.boldSystemFont(18)
texti.textColor = Color.red()
texti.shadowColor = Color.black()
texti.shadowOffset = new Point(2,2)
texti.shadowRadius = 1
texti.rightAlignText()
row = w.addStack()
texti = row.addText("PTU:")
texti.font = Font.boldSystemFont(18)
texti.textColor = Color.red()
texti.shadowColor = Color.black()
texti.shadowOffset = new Point(1,1)
texti.shadowRadius = 1
row.addSpacer()
texti = row.addText(ptu)
texti.font = Font.boldSystemFont(18)
texti.textColor = Color.red()
texti.shadowColor = Color.black()
texti.shadowOffset = new Point(2,2)
texti.shadowRadius = 1
texti.rightAlignText()
return w
}
function sleep(milliseconds) {
var startTime = new Date().getTime()
while (new Date().getTime() < startTime + milliseconds)
{}
}
// <p>Live Version: 3.13.1 (<a href="https://robertsspaceindustries.com/comm-link/transmission/18021-Alpha-313-Underground-Infamy" target="_blank">more info</a>)
// ▪ Latest Roadmap Roundup: 06/30/2021 (<a href="https://robertsspaceindustries.com/comm-link?series=roadmap-roundup" target="_blank">more info</a>)
// ▪ PTU Version: 3.14.0</p></div></div></div></header>