Skip to content

Commit a1ce4f6

Browse files
committed
feat: add hztsg-wifi
1 parent a35c186 commit a1ce4f6

11 files changed

Lines changed: 223 additions & 83 deletions

File tree

package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@
1919
"prettier": "^3.6.2",
2020
"simple-git-hooks": "^2.13.1"
2121
},
22-
"sync": [
23-
"prettier",
24-
"commitlint",
25-
"simplehooks"
26-
],
2722
"simple-git-hooks": {
2823
"pre-commit": "npx lint-staged"
2924
},

packages/hztsg-wifi/.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
.output
12+
stats.html
13+
stats-*.json
14+
.wxt
15+
web-ext.config.ts
16+
.env.local
17+
18+
# Editor directories and files
19+
.vscode/*
20+
!.vscode/extensions.json
21+
.idea
22+
.DS_Store
23+
*.suo
24+
*.ntvs*
25+
*.njsproj
26+
*.sln
27+
*.sw?

packages/hztsg-wifi/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Hangzhou Library Wifi Auto Login
2+
3+
A userscript that enables automatic login to the Hangzhou Library Wifi.
4+
5+
## Installation
6+
7+
1. Install a userscript manager like [Tampermonkey](https://www.tampermonkey.net/) or [Greasemonkey](https://www.greasespot.net/)
8+
2. Download the userscript from <https://github.com/rxliuli/userscripts/releases/latest/download/hz-library-wifi.user.js>
9+
10+
## How to Use
11+
12+
1. **Visit the Login Page**: Navigate to the Hangzhou Library Wifi login page
13+
2. **Start Typing**: Enter your library account and password
14+
3. **Use the Shortcut**: Press Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac)
15+
4. **Auto Submit**: The script automatically finds and clicks the appropriate submit/save button

packages/hztsg-wifi/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "hztsg-wifi",
3+
"description": "Automatically log in to the Hangzhou Library Wifi.",
4+
"private": true,
5+
"version": "0.1.1",
6+
"type": "module",
7+
"scripts": {
8+
"build": "vite build",
9+
"test": "vitest run"
10+
},
11+
"devDependencies": {
12+
"@types/node": "^22.15.30",
13+
"@types/tampermonkey": "^5.0.4",
14+
"@vitest/browser": "^3.2.2",
15+
"playwright": "^1.52.0",
16+
"typescript": "^5.8.3",
17+
"vite": "^6.3.5",
18+
"vite-node": "^3.2.4",
19+
"vite-plugin-monkey": "^7.0.3",
20+
"vite-tsconfig-paths": "^5.1.4",
21+
"vitest": "^3.2.2",
22+
"vitest-browser-react": "^0.2.0",
23+
"zx": "^8.5.5"
24+
}
25+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
async function main() {
2+
let username = await GM.getValue<string>('username')
3+
if (!username) {
4+
const result = prompt('Please enter your library account:')
5+
if (!result) {
6+
alert('No account entered, script terminated')
7+
return
8+
}
9+
await GM.setValue('username', result)
10+
username = result
11+
}
12+
let password = await GM.getValue<string>('password')
13+
if (!password) {
14+
const result = prompt('Please enter your library password:')
15+
if (!result) {
16+
alert('No password entered, script terminated')
17+
return
18+
}
19+
await GM.setValue('password', result)
20+
password = result
21+
}
22+
23+
const $name = document.querySelector('#password_name') as HTMLInputElement
24+
$name.value = username
25+
const $pwd = document.querySelector('#password_pwd') as HTMLInputElement
26+
$pwd.value = password
27+
const $remeber = document.querySelector('#rememberPwd') as HTMLInputElement
28+
$remeber.checked = true
29+
const $password_disclaimer = document.querySelector('#password_disclaimer') as HTMLInputElement
30+
$password_disclaimer.checked = true
31+
const $submitBtn = document.querySelector('#password_submitBtn') as HTMLButtonElement
32+
$submitBtn.click()
33+
setTimeout(() => {
34+
window.close()
35+
}, 1000)
36+
}
37+
38+
main()

packages/hztsg-wifi/tsconfig.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"useDefineForClassFields": true,
5+
"module": "ESNext",
6+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
7+
"skipLibCheck": true,
8+
9+
"moduleResolution": "bundler",
10+
"allowImportingTsExtensions": true,
11+
"verbatimModuleSyntax": true,
12+
"moduleDetection": "force",
13+
"noEmit": true,
14+
15+
"strict": true,
16+
"noUnusedLocals": true,
17+
"noUnusedParameters": true,
18+
"erasableSyntaxOnly": true,
19+
"noFallthroughCasesInSwitch": true,
20+
"noUncheckedSideEffectImports": true
21+
},
22+
"include": ["src"]
23+
}

packages/hztsg-wifi/vite.config.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { defineConfig } from 'vite'
2+
import monkey from 'vite-plugin-monkey'
3+
4+
export default defineConfig({
5+
plugins: [
6+
monkey({
7+
entry: 'src/userscript.ts',
8+
userscript: {
9+
name: 'Hangzhou Library Wifi Auto Login',
10+
namespace: 'https://rxliuli.com',
11+
description: 'Automatically log in to the Hangzhou Library Wifi.',
12+
match: ['http://3.3.3.3/ac_portal/*/pc.html?*'],
13+
author: 'rxliuli',
14+
license: 'GPL-3.0-only',
15+
version: (await import('../../package.json')).version,
16+
},
17+
}),
18+
],
19+
publicDir: false,
20+
})
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { defineConfig } from 'vitest/config'
2+
import tsconfigPaths from 'vite-tsconfig-paths'
3+
4+
export default defineConfig({
5+
test: {
6+
projects: [
7+
{
8+
plugins: [tsconfigPaths()] as any,
9+
test: {
10+
exclude: ['**/*.unit.test.ts', 'node_modules/**'],
11+
browser: {
12+
enabled: true,
13+
provider: 'playwright',
14+
// https://vitest.dev/guide/browser/playwright
15+
instances: [{ browser: 'chromium', headless: true }],
16+
},
17+
},
18+
},
19+
{
20+
plugins: [tsconfigPaths()] as any,
21+
test: {
22+
include: ['**/*.unit.test.ts'],
23+
exclude: ['*.test.ts', 'node_modules/**'],
24+
},
25+
},
26+
],
27+
},
28+
})

packages/reddit-ctrl-enter-sender/package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,5 @@
2020
"vitest": "^3.2.2",
2121
"vitest-browser-react": "^0.2.0",
2222
"zx": "^8.5.5"
23-
},
24-
"packageManager": "pnpm@10.5.2+sha512.da9dc28cd3ff40d0592188235ab25d3202add8a207afbedc682220e4a0029ffbff4562102b9e6e46b4e3f9e8bd53e6d05de48544b0c57d4b0179e22c76d1199b",
25-
"dependencies": {
26-
"@medv/finder": "^4.0.2",
27-
"@rxliuli/vista": "^0.4.0"
2823
}
2924
}

packages/youtube-music-background-play/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
"vitest-browser-react": "^0.2.0",
2222
"zx": "^8.5.5"
2323
},
24-
"packageManager": "pnpm@10.5.2+sha512.da9dc28cd3ff40d0592188235ab25d3202add8a207afbedc682220e4a0029ffbff4562102b9e6e46b4e3f9e8bd53e6d05de48544b0c57d4b0179e22c76d1199b",
2524
"dependencies": {
2625
"@medv/finder": "^4.0.2",
2726
"@rxliuli/vista": "^0.4.0"

0 commit comments

Comments
 (0)