Skip to content

Commit e06f596

Browse files
committed
💥 Support full features
1 parent 4d57fe5 commit e06f596

File tree

7 files changed

+251
-77
lines changed

7 files changed

+251
-77
lines changed

.gitignore

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
*.zip
2+
package-lock.json
3+
yarn.lock
4+
.yarnrc.yml
5+
.yarn/
6+
7+
# create by https://github.com/iamcco/coc-gitignore (Fri Mar 07 2025 15:53:33 GMT+0800 (China Standard Time))
8+
# Node.gitignore:
9+
# Logs
10+
logs
11+
*.log
12+
npm-debug.log*
13+
yarn-debug.log*
14+
yarn-error.log*
15+
lerna-debug.log*
16+
17+
# Diagnostic reports (https://nodejs.org/api/report.html)
18+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
19+
20+
# Runtime data
21+
pids
22+
*.pid
23+
*.seed
24+
*.pid.lock
25+
26+
# Directory for instrumented libs generated by jscoverage/JSCover
27+
lib-cov
28+
29+
# Coverage directory used by tools like istanbul
30+
coverage
31+
*.lcov
32+
33+
# nyc test coverage
34+
.nyc_output
35+
36+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
37+
.grunt
38+
39+
# Bower dependency directory (https://bower.io/)
40+
bower_components
41+
42+
# node-waf configuration
43+
.lock-wscript
44+
45+
# Compiled binary addons (https://nodejs.org/api/addons.html)
46+
build/Release
47+
48+
# Dependency directories
49+
node_modules/
50+
jspm_packages/
51+
52+
# TypeScript v1 declaration files
53+
typings/
54+
55+
# TypeScript cache
56+
*.tsbuildinfo
57+
58+
# Optional npm cache directory
59+
.npm
60+
61+
# Optional eslint cache
62+
.eslintcache
63+
64+
# Optional REPL history
65+
.node_repl_history
66+
67+
# Output of 'npm pack'
68+
*.tgz
69+
70+
# Yarn Integrity file
71+
.yarn-integrity
72+
73+
# dotenv environment variables file
74+
.env
75+
.env.test
76+
77+
# parcel-bundler cache (https://parceljs.org/)
78+
.cache
79+
80+
# next.js build output
81+
.next
82+
83+
# nuxt.js build output
84+
.nuxt
85+
86+
# vuepress build output
87+
.vuepress/dist
88+
89+
# Serverless directories
90+
.serverless/
91+
92+
# FuseBox cache
93+
.fusebox/
94+
95+
# DynamoDB Local files
96+
.dynamodb/

README.md

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,44 @@
11
# browser-bitahub
22

3-
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Freed-Wu/browser-bitahub/main.svg)](https://results.pre-commit.ci/latest/github/Freed-Wu/browser-bitahub/main)
4-
5-
[![github/downloads](https://shields.io/github/downloads/Freed-Wu/browser-bitahub/total)](https://github.com/Freed-Wu/browser-bitahub/releases)
6-
[![github/downloads/latest](https://shields.io/github/downloads/Freed-Wu/browser-bitahub/latest/total)](https://github.com/Freed-Wu/browser-bitahub/releases/latest)
7-
[![github/issues](https://shields.io/github/issues/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub/issues)
8-
[![github/issues-closed](https://shields.io/github/issues-closed/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub/issues?q=is%3Aissue+is%3Aclosed)
9-
[![github/issues-pr](https://shields.io/github/issues-pr/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub/pulls)
10-
[![github/issues-pr-closed](https://shields.io/github/issues-pr-closed/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub/pulls?q=is%3Apr+is%3Aclosed)
11-
[![github/discussions](https://shields.io/github/discussions/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub/discussions)
12-
[![github/milestones](https://shields.io/github/milestones/all/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub/milestones)
13-
[![github/forks](https://shields.io/github/forks/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub/network/members)
14-
[![github/stars](https://shields.io/github/stars/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub/stargazers)
15-
[![github/watchers](https://shields.io/github/watchers/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub/watchers)
16-
[![github/contributors](https://shields.io/github/contributors/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub/graphs/contributors)
17-
[![github/commit-activity](https://shields.io/github/commit-activity/w/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub/graphs/commit-activity)
18-
[![github/last-commit](https://shields.io/github/last-commit/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub/commits)
19-
[![github/release-date](https://shields.io/github/release-date/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub/releases/latest)
20-
21-
[![github/license](https://shields.io/github/license/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub/blob/main/LICENSE)
22-
[![github/languages](https://shields.io/github/languages/count/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub)
23-
[![github/languages/top](https://shields.io/github/languages/top/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub)
24-
[![github/directory-file-count](https://shields.io/github/directory-file-count/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub)
25-
[![github/code-size](https://shields.io/github/languages/code-size/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub)
26-
[![github/repo-size](https://shields.io/github/repo-size/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub)
27-
[![github/v](https://shields.io/github/v/release/Freed-Wu/browser-bitahub)](https://github.com/Freed-Wu/browser-bitahub)
3+
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/ustc-ivclab/browser-bitahub/main.svg)](https://results.pre-commit.ci/latest/github/ustc-ivclab/browser-bitahub/main)
4+
5+
[![github/downloads](https://shields.io/github/downloads/ustc-ivclab/browser-bitahub/total)](https://github.com/ustc-ivclab/browser-bitahub/releases)
6+
[![github/downloads/latest](https://shields.io/github/downloads/ustc-ivclab/browser-bitahub/latest/total)](https://github.com/ustc-ivclab/browser-bitahub/releases/latest)
7+
[![github/issues](https://shields.io/github/issues/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub/issues)
8+
[![github/issues-closed](https://shields.io/github/issues-closed/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub/issues?q=is%3Aissue+is%3Aclosed)
9+
[![github/issues-pr](https://shields.io/github/issues-pr/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub/pulls)
10+
[![github/issues-pr-closed](https://shields.io/github/issues-pr-closed/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub/pulls?q=is%3Apr+is%3Aclosed)
11+
[![github/discussions](https://shields.io/github/discussions/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub/discussions)
12+
[![github/milestones](https://shields.io/github/milestones/all/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub/milestones)
13+
[![github/forks](https://shields.io/github/forks/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub/network/members)
14+
[![github/stars](https://shields.io/github/stars/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub/stargazers)
15+
[![github/watchers](https://shields.io/github/watchers/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub/watchers)
16+
[![github/contributors](https://shields.io/github/contributors/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub/graphs/contributors)
17+
[![github/commit-activity](https://shields.io/github/commit-activity/w/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub/graphs/commit-activity)
18+
[![github/last-commit](https://shields.io/github/last-commit/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub/commits)
19+
[![github/release-date](https://shields.io/github/release-date/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub/releases/latest)
20+
21+
[![github/license](https://shields.io/github/license/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub/blob/main/LICENSE)
22+
[![github/languages](https://shields.io/github/languages/count/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub)
23+
[![github/languages/top](https://shields.io/github/languages/top/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub)
24+
[![github/directory-file-count](https://shields.io/github/directory-file-count/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub)
25+
[![github/code-size](https://shields.io/github/languages/code-size/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub)
26+
[![github/repo-size](https://shields.io/github/repo-size/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub)
27+
[![github/v](https://shields.io/github/v/release/ustc-ivclab/browser-bitahub)](https://github.com/ustc-ivclab/browser-bitahub)
2828

2929
Display [bitahub](https://bitahub.ustc.edu.cn/resources) GPU status in browser.
30+
31+
![screenshot](https://github.com/user-attachments/assets/ca8c33ab-f6f0-4fff-99e4-8d0fe8812bd2)
32+
33+
Also support firefox on Android.
34+
35+
![android](https://github.com/user-attachments/assets/497ce79f-539a-4f6e-a1cb-7f6e792a34b0)
36+
37+
## Install
38+
39+
- [firefox](https://addons.mozilla.org/en-US/firefox/addon/bitahub/)
40+
- [firefox on Android](https://addons.mozilla.org/en-US/android/addon/bitahub/)
41+
42+
## Related Projects
43+
44+
- [tmux-bitahub](https://github.com/ustc-ivclab/tmux-bitahub)

assets/css/index.css

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ th,
1010
td {
1111
border: 1px solid #666;
1212
padding: 5px;
13+
text-align: center;
1314
}
1415

1516
/* th单元格 */
1617
.slash-wrap {
1718
position: relative;
1819
box-sizing: border-box;
19-
width: 60px;
20-
height: 45px;
20+
/* 3:4:5 */
21+
height: 52.5px;
22+
width: 70px;
2123
}
2224

2325
/* 斜线 */
@@ -27,7 +29,7 @@ td {
2729
top: 0;
2830
left: 0;
2931
/* Math.sqrt(Math.pow(width, 2) + Math.pow(height, 2)) */
30-
width: 75px;
32+
width: 87.5px;
3133
height: 1px;
3234
background-color: #000;
3335
/* Math.atan(height / width) * 180 / Math.PI */
@@ -49,12 +51,23 @@ td {
4951
top: 0px;
5052
}
5153

54+
td {
55+
color: orange;
56+
}
57+
5258
.item {
53-
text-align: center;
5459
cursor: pointer;
5560
background-color: #e5f2f2;
5661
}
5762

5863
.item:hover {
5964
background-color: #cff2f2;
6065
}
66+
67+
.full {
68+
color: green;
69+
}
70+
71+
.zero {
72+
color: red;
73+
}

assets/js/index.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,44 @@
1-
document.body.style.border = "5px solid red";
1+
const parser = new DOMParser();
2+
const number_gpu_max = 8
3+
4+
let resources = ["gtx1080ti", "rtx3090", "teslav100"];
5+
for (const resource of resources) {
6+
fetch("https://bitahub.ustc.edu.cn/resources/" + resource)
7+
.then((response) => {
8+
if (!response.ok) {
9+
throw new Error("Network failure");
10+
}
11+
return response.text();
12+
})
13+
.then((html) => {
14+
const doc = parser.parseFromString(html, "text/html");
15+
let numbers = [];
16+
for (const [i, td] of doc.querySelectorAll("td").entries()) {
17+
if (i % 7 === 1) {
18+
numbers.push(Number(td.textContent))
19+
}
20+
}
21+
const tr = document.querySelector("#" + resource)
22+
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
25+
}
26+
}
27+
for (const element of tr.querySelectorAll(Array.from({length: number_gpu_max}, (_, index) => ".n" + (index + 1)).join())) {
28+
const number = Number(element.textContent);
29+
if (number === 0) {
30+
element.classList.add("zero");
31+
} else if (number >= numbers.reduce((accumulator, currentValue) => accumulator + currentValue, 0) / (number_gpu_max + 1)) {
32+
element.classList.add("full");
33+
}
34+
}
35+
})
36+
.catch((error) => {
37+
for (const element of document.querySelectorAll(".hidden")) {
38+
element.classList.remove("hidden");
39+
for (const p of element.querySelectorAll("p")) {
40+
p.textContent = error;
41+
}
42+
}
43+
});
44+
}

index.html

Lines changed: 39 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,51 @@
99
<table id="popup-content">
1010
<tr>
1111
<th class="slash-wrap">
12-
<span class="left">GPU</span>
12+
<span class="left"><a href="https://bitahub.ustc.edu.cn/resources" title="https://bitahub.ustc.edu.cn/resources">GPU</a></span>
1313
<span class="slash"></span>
14-
<span class="right">free</span>
14+
<span class="right"><a href="https://bitahub.ustc.edu.cn/" title="https://bitahub.ustc.edu.cn/">free</a></span>
1515
</th>
16-
<th>0</th>
17-
<th>1</th>
18-
<th>2</th>
19-
<th>3</th>
20-
<th>4</th>
21-
<th>5</th>
22-
<th>6</th>
23-
<th>7</th>
2416
<th>8</th>
17+
<th>7</th>
18+
<th>6</th>
19+
<th>5</th>
20+
<th>4</th>
21+
<th>3</th>
22+
<th>2</th>
23+
<th>1</th>
2524
</tr>
26-
<tr id="1080ti">
27-
<td class="item">1080ti</td>
28-
<td class="number">0</td>
29-
<td class="number">0</td>
30-
<td class="number">0</td>
31-
<td class="number">0</td>
32-
<td class="number">0</td>
33-
<td class="number">0</td>
34-
<td class="number">0</td>
35-
<td class="number">0</td>
36-
<td class="number">0</td>
25+
<tr id="gtx1080ti">
26+
<td class="item"><a href="https://bitahub.ustc.edu.cn/resources/gtx1080ti" title="https://bitahub.ustc.edu.cn/resources/gtx1080ti">1080ti</a></td>
27+
<td class="n8">0</td>
28+
<td class="n7">0</td>
29+
<td class="n6">0</td>
30+
<td class="n5">0</td>
31+
<td class="n4">0</td>
32+
<td class="n3">0</td>
33+
<td class="n2">0</td>
34+
<td class="n1">0</td>
3735
</tr>
38-
<tr id="3090">
39-
<td class="item">3090</td>
40-
<td class="number">0</td>
41-
<td class="number">0</td>
42-
<td class="number">0</td>
43-
<td class="number">0</td>
44-
<td class="number">0</td>
45-
<td class="number">0</td>
46-
<td class="number">0</td>
47-
<td class="number">0</td>
48-
<td class="number">0</td>
36+
<tr id="rtx3090">
37+
<td class="item"><a href="https://bitahub.ustc.edu.cn/resources/rtx3090" title="https://bitahub.ustc.edu.cn/resources/rtx3090">3090</a></td>
38+
<td class="n8">0</td>
39+
<td class="n7">0</td>
40+
<td class="n6">0</td>
41+
<td class="n5">0</td>
42+
<td class="n4">0</td>
43+
<td class="n3">0</td>
44+
<td class="n2">0</td>
45+
<td class="n1">0</td>
4946
</tr>
50-
<tr id="v100">
51-
<td class="item">v100</td>
52-
<td class="number">0</td>
53-
<td class="number">0</td>
54-
<td class="number">0</td>
55-
<td class="number">0</td>
56-
<td class="number">0</td>
57-
<td class="number">0</td>
58-
<td class="number">0</td>
59-
<td class="number">0</td>
60-
<td class="number">0</td>
47+
<tr id="teslav100">
48+
<td class="item"><a href="https://bitahub.ustc.edu.cn/resources/teslav100" title="https://bitahub.ustc.edu.cn/resources/teslav100">v100</a></td>
49+
<td class="n8">0</td>
50+
<td class="n7">0</td>
51+
<td class="n6">0</td>
52+
<td class="n5">0</td>
53+
<td class="n4">0</td>
54+
<td class="n3">0</td>
55+
<td class="n2">0</td>
56+
<td class="n1">0</td>
6157
</tr>
6258
</table>
6359
<div id="error-content" class="hidden">

manifest.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
{
2-
"manifest_version": 2,
2+
"manifest_version": 3,
33
"name": "bitahub",
44
"version": "1.0",
55
"description": "Display GPU information of bitahub",
6+
"host_permissions": [
7+
"https://bitahub.ustc.edu.cn/resources"
8+
],
69
"icons": {
710
"48": "assets/icons/48.png"
811
},
9-
"browser_action": {
12+
"action": {
1013
"default_title": "bitahub",
1114
"default_popup": "index.html"
12-
}
15+
},
16+
"browser_specific_settings": {
17+
"gecko": {
18+
19+
}
20+
}
1321
}

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
{
22
"devDependencies": {
3+
"@biomejs/biome": "*",
34
"web-ext": "*"
45
},
56
"scripts": {
6-
"run": "web-ext run"
7+
"build": "web-ext build --overwrite-dest",
8+
"run": "web-ext run",
9+
"check": "web-ext lint && biome check"
710
}
811
}

0 commit comments

Comments
 (0)