Skip to content

Commit ea61edf

Browse files
committed
🎨 Format code by biome
1 parent e06f596 commit ea61edf

File tree

4 files changed

+41
-22
lines changed

4 files changed

+41
-22
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ Display [bitahub](https://bitahub.ustc.edu.cn/resources) GPU status in browser.
3030

3131
![screenshot](https://github.com/user-attachments/assets/ca8c33ab-f6f0-4fff-99e4-8d0fe8812bd2)
3232

33-
Also support firefox on Android.
33+
Also support firefox for Android.
3434

3535
![android](https://github.com/user-attachments/assets/497ce79f-539a-4f6e-a1cb-7f6e792a34b0)
3636

3737
## Install
3838

3939
- [firefox](https://addons.mozilla.org/en-US/firefox/addon/bitahub/)
40-
- [firefox on Android](https://addons.mozilla.org/en-US/android/addon/bitahub/)
40+
- [firefox for Android](https://addons.mozilla.org/en-US/android/addon/bitahub/)
4141

4242
## Related Projects
4343

File renamed without changes.

assets/js/index.js

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const parser = new DOMParser();
2-
const number_gpu_max = 8
2+
const number_gpu_max = 8;
33

4-
let resources = ["gtx1080ti", "rtx3090", "teslav100"];
4+
const resources = ["gtx1080ti", "rtx3090", "teslav100"];
55
for (const resource of resources) {
6-
fetch("https://bitahub.ustc.edu.cn/resources/" + resource)
6+
fetch(`https://bitahub.ustc.edu.cn/resources/${resource}`)
77
.then((response) => {
88
if (!response.ok) {
99
throw new Error("Network failure");
@@ -12,23 +12,35 @@ for (const resource of resources) {
1212
})
1313
.then((html) => {
1414
const doc = parser.parseFromString(html, "text/html");
15-
let numbers = [];
15+
const numbers = [];
1616
for (const [i, td] of doc.querySelectorAll("td").entries()) {
1717
if (i % 7 === 1) {
18-
numbers.push(Number(td.textContent))
18+
numbers.push(Number(td.textContent));
1919
}
2020
}
21-
const tr = document.querySelector("#" + resource)
21+
const tr = document.querySelector(`#${resource}`);
2222
for (let i = 1, len = number_gpu_max + 1; i < len; i++) {
23-
for (const td of tr.querySelectorAll(".n" + i)) {
24-
td.textContent = numbers.filter(x => x == i).length
23+
for (const td of tr.querySelectorAll(`.n${i}`)) {
24+
td.textContent = numbers.filter((x) => x === i).length;
2525
}
2626
}
27-
for (const element of tr.querySelectorAll(Array.from({length: number_gpu_max}, (_, index) => ".n" + (index + 1)).join())) {
27+
for (const element of tr.querySelectorAll(
28+
Array.from(
29+
{ length: number_gpu_max },
30+
(_, index) => `.n${index + 1}`,
31+
).join(),
32+
)) {
2833
const number = Number(element.textContent);
2934
if (number === 0) {
3035
element.classList.add("zero");
31-
} else if (number >= numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0) / (number_gpu_max + 1)) {
36+
} else if (
37+
number >=
38+
numbers.reduce(
39+
(accumulator, currentValue) => accumulator + currentValue,
40+
0,
41+
) /
42+
(number_gpu_max + 1)
43+
) {
3244
element.classList.add("full");
3345
}
3446
}

manifest.json

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,28 @@
11
{
22
"manifest_version": 3,
33
"name": "bitahub",
4-
"version": "1.0",
4+
"version": "0.1",
5+
"author": "Wu, Zhenyu",
6+
"homepage_url": "https://github.com/ustc-ivclab/browser-bitahub",
57
"description": "Display GPU information of bitahub",
6-
"host_permissions": [
7-
"https://bitahub.ustc.edu.cn/resources"
8-
],
8+
"host_permissions": ["https://bitahub.ustc.edu.cn/resources"],
99
"icons": {
10-
"48": "assets/icons/48.png"
10+
"48": "assets/images/48.png"
1111
},
1212
"action": {
1313
"default_title": "bitahub",
1414
"default_popup": "index.html"
1515
},
16-
"browser_specific_settings": {
17-
"gecko": {
18-
19-
}
20-
}
16+
"browser_specific_settings": {
17+
"gecko": {
18+
19+
}
20+
},
21+
"commands": {
22+
"_execute_action": {
23+
"suggested_key": {
24+
"default": "Ctrl+Alt+B"
25+
}
26+
}
27+
}
2128
}

0 commit comments

Comments
 (0)