├── CC98_sign_in ├── cc98_autosign.ps1 ├── cc98_autosign.sh ├── cc98_curl.ps1 ├── cc98_curl.sh └── cc98_password.txt ├── LICENSE ├── NexusHD_sign_in ├── nhd_autosign.ps1 ├── nhd_autosign.sh ├── nhd_curl.ps1 ├── nhd_curl.sh └── nhd_password.txt ├── README.md └── ZJU-Sign-in-ClassRoom-Alert.js /CC98_sign_in/cc98_autosign.ps1: -------------------------------------------------------------------------------- 1 | # cc98_autosign.ps1 2 | # Reads username and password from a list 3 | # and sign in for CC98. 4 | # required password file format: 5 | # in each line, username:password (separated by colon and nothing else) 6 | 7 | $pwfile = "cc98_password.txt" 8 | Get-Content $pwfile | ForEach-Object { 9 | $username,$password = $_ -split ":" 10 | ./cc98_curl.ps1 $username $password 11 | } 12 | -------------------------------------------------------------------------------- /CC98_sign_in/cc98_autosign.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # cc98_autosign.sh 3 | # Reads username and password from a list 4 | # and sign in for CC98. 5 | # required password file format: 6 | # in each line, username:password (separated by colon and nothing else) 7 | pwfile="cc98_password.txt" 8 | while IFS=: read -r username password 9 | do 10 | # printf 'Username: %s password: %s\n' "$username" "$password" 11 | # echo "$username" "$password" 12 | ./cc98_curl.sh $username $password 13 | done <"$pwfile" -------------------------------------------------------------------------------- /CC98_sign_in/cc98_curl.ps1: -------------------------------------------------------------------------------- 1 | # cc98_curl.ps1 2 | # Automatically helps you sign in to CC98 with your given username and password 3 | # usage: .\cc98_curl.ps1 username password 4 | 5 | $Username = $args[0] 6 | $Password = $args[1] 7 | 8 | # Login with username and password, extracts and stores token in a variable. 9 | $Token = curl https://openid.cc98.org/connect/token -d "client_id=9a1fd200-8687-44b1-4c20-08d50a96e5cd&client_secret=8b53f727-08e2-4509-8857-e34bf92b27f2&grant_type=password" --data-urlencode "username=$Username" --data-urlencode "password=$Password" | Select-String -Pattern 'access_token":"(.+?)"' | Foreach-Object { "Bearer $($_.Matches.Groups[1].Value)" } 10 | 11 | # post message to sign in api. 12 | # pre-flight 13 | # Invoke-WebRequest -Uri "https://api.cc98.org/me/signin" -Method OPTIONS -Headers @{ "Access-Control-Request-Headers" = "authorization,content-type"; "Access-Control-Request-Method" = "POST" } 14 | 15 | $Coins = curl -X POST --header "content-length:0" --header "content-type:application/json" --header "authorization:$Token" https://api.cc98.org/me/signin 16 | 17 | # log 18 | Add-Content -Path "log.txt" -Value "CC98 signed in for $Username at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss'), and got `$${Coins.Content}." 19 | -------------------------------------------------------------------------------- /CC98_sign_in/cc98_curl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # cc98_curl.sh 3 | # Automatically helps you sign in to CC98 with your given username and password 4 | # usage: cc98_curl.sh username password 5 | username=$1 6 | password=$2 7 | # Login with username and password, extracts and stores token in a variable. 8 | token=$(curl https://openid.cc98.org/connect/token -d "client_id=9a1fd200-8687-44b1-4c20-08d50a96e5cd&client_secret=8b53f727-08e2-4509-8857-e34bf92b27f2&grant_type=password" --data-urlencode "username=${username}" --data-urlencode "password=${password}" | sed 's/.*"access_token":"\([^"]*\)".*/Bearer \1/') 9 | # post message to sign in api. 10 | # pre-flight 11 | # curl -X OPTIONS --header "access-control-request-headers: authorization,content-type" --header "access-control-request-method: POST" -v # Not necessary 12 | coins=$(curl -X POST --header "content-length:0" --header "content-type:application/json" --header "authorization:$token" https://api.cc98.org/me/signin) 13 | # log 14 | echo "CC98 signed in for ${username} at" $(date "+%Y-%m-%d %H:%M:%S")", and got \$${coins}". >> log.txt -------------------------------------------------------------------------------- /CC98_sign_in/cc98_password.txt: -------------------------------------------------------------------------------- 1 | 吴朝晖:myCC98myHome 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Shaw Haines 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /NexusHD_sign_in/nhd_autosign.ps1: -------------------------------------------------------------------------------- 1 | # nhd_autosign.ps1 2 | # Reads username and password from a list 3 | # and sign in for NexusHD. 4 | # required password file format: 5 | # in each line, username:password (separated by colon and nothing else) 6 | 7 | $pwfile = "nhd_password.txt" 8 | Get-Content $pwfile | ForEach-Object { 9 | $username,$password = $_ -split ":" 10 | ./nhd_curl.ps1 $username $password 11 | } -------------------------------------------------------------------------------- /NexusHD_sign_in/nhd_autosign.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # nhd_autosign.sh 3 | # Reads username and password from a list 4 | # and sign in for NexusHD. 5 | # required password file format: 6 | # in each line, username:password (separated by colon and nothing else) 7 | pwfile="nhd_password.txt" 8 | while IFS=: read -r username password 9 | do 10 | # printf 'Username: %s password: %s\n' "$username" "$password" 11 | # echo "$username" "$password" 12 | ./nhd_curl.sh $username $password 13 | done <"$pwfile" 14 | -------------------------------------------------------------------------------- /NexusHD_sign_in/nhd_curl.ps1: -------------------------------------------------------------------------------- 1 | # nhd_curl.ps1 2 | # Automatically helps you sign in to NexusHD with your given username and password 3 | # usage: .\nhd_curl.ps1 username password 4 | 5 | $Username = $args[0] 6 | $Password = $args[1] 7 | $Cookies = "${Username}_cookies.txt" 8 | 9 | # Login with username and password, sets auto jump, stores cookies in cookies file. 10 | curl -d "username=${username}&password=${password}&logout=yes" -L -c $cookies http://www.nexushd.org/takelogin.php -e http://www.nexushd.org/login.php 11 | # send message [em176][em52] to sign in. 12 | curl -b $cookies --data-urlencode "action=post" --data-urlencode "content=[em176][em52]" http://www.nexushd.org/signin.php 13 | 14 | # Use this address instead for ipv6 accessing. 15 | # curl -d "username=${username}&password=${password}&logout=yes" -L -c $cookies https://v6.nexushd.org/takelogin.php -e https://v6.nexushd.org/login.php 16 | # curl -b $cookies --data-urlencode "action=post" --data-urlencode "content=[em176][em52]" https://v6.nexushd.org/signin.php 17 | 18 | # log 19 | Add-Content -Path "log.txt" -Value "NHD signed in for $Username at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" 20 | -------------------------------------------------------------------------------- /NexusHD_sign_in/nhd_curl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # nhd_curl.sh 3 | # Automatically helps you sign in to NexusHD with your given username and password 4 | # usage: nhd_curl.sh username password 5 | username=$1 6 | password=$2 7 | cookies="${username}_cookies.txt" 8 | # Login with username and password, sets auto jump, stores cookies in cookies file. 9 | curl -d "username=${username}&password=${password}&logout=yes" -L -c $cookies http://www.nexushd.org/takelogin.php -e http://www.nexushd.org/login.php 10 | # send message [em176][em52] to sign in. 11 | curl -b $cookies --data-urlencode "action=post" --data-urlencode "content=[em176][em52]" http://www.nexushd.org/signin.php 12 | 13 | # Use this address instead for ipv6 accessing. 14 | # curl -d "username=${username}&password=${password}&logout=yes" -L -c $cookies https://v6.nexushd.org/takelogin.php -e https://v6.nexushd.org/login.php 15 | # curl -b $cookies --data-urlencode "action=post" --data-urlencode "content=[em176][em52]" https://v6.nexushd.org/signin.php 16 | 17 | # log 18 | echo "NHD signed in for ${username} at" $(date "+%Y-%m-%d %H:%M:%S") >> log.txt -------------------------------------------------------------------------------- /NexusHD_sign_in/nhd_password.txt: -------------------------------------------------------------------------------- 1 | ZhaohuiWu:pretend_I_am_a_password 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # evilScripts 2 | 3 | Some evil script collection useful in Zhejiang University. 4 | 5 | * `ZJU-Sign-in-ClassRoom-Alert.js`(浙江大学智云课堂签到提示) An assistant that watches the subtitles on ZJU classroom (浙江大学智云课堂) and sends you alert when the teacher asks to sign in. 6 | * `NexusHD_sign_in/` A shell script based on curl that automatically signs in for you on [NexusHD](http://www.nexushd.org) (a private torrent website exclusive to ZJU members). 7 | * `CC98_sigin_in/` A shell script based on curl that automatically signs in for you on [CC98](https://www.cc98.org) (an internal forum also exclusive to ZJU members). 8 | 9 | ## ZJU-Sign-in-ClassRoom-Alert 10 | 11 | ~~Available on [Greasy Fork](https://greasyfork.org/en/)~~ 12 | 13 | Copy & paste the content into a [Tampermonkey](https://www.tampermonkey.net) script. 14 | 15 | 16 | ## NexusHD_sign_in 17 | 18 | It's a minimalist script inspired by [XinArkh/NexusHD_AutoCheck](https://github.com/XinArkh/NexusHD_AutoCheck). Unlike its predecessor, it is based on `curl` that does not depend on any additional libraries, or python. 19 | 20 | Prerequsite: accessible to ZJU internal network. 21 | 22 | ### Single user, temporary run 23 | 24 | Navigate to the folder containing the scripts, simply type 25 | 26 | ```bash 27 | ./nhd_curl.sh 28 | ``` 29 | 30 | ### Multiple users 31 | 32 | Fill in your list of username and password in the **local** copy of [nhd_password.txt](./NexusHD_sign_in/nhd_password.txt) 33 | 34 | Format specification: In each line, `username:password` (separated by half-width colon and nothing else) 35 | 36 | example: 37 | 38 | ``` 39 | ZhaohuiWu:123456 40 | PeppaPig:123456 41 | ``` 42 | 43 | Run 44 | 45 | ``` 46 | ./nhd_autosign.sh 47 | ``` 48 | 49 | ### Scheduled task 50 | 51 | On Linux or OpenWRT server, use `crontab` command to setup scheduled task. 52 | 53 | ```bash 54 | # edit scheduled task 55 | crontab -e 56 | ``` 57 | 58 | In the editor that follows, type 59 | 60 | ```bash 61 | # automatically sign in for NHD at 08:00 am everyday. 62 | 00 08 * * * cd /path/to/script; ./nhd_autosign.sh 63 | ``` 64 | 65 | ### CC98_sign_in 66 | 67 | An expansion to `NexusHD_sign_in`. Its usage is similar to [NexusHD_sign_in](#nexushd_sign_in) -------------------------------------------------------------------------------- /ZJU-Sign-in-ClassRoom-Alert.js: -------------------------------------------------------------------------------- 1 | // ==UserScript== 2 | // @name 浙江大学智云课堂签到提示 ZJU Sign-in ClassRoom Alert 3 | // @namespace https://github.com/ShawHaines/evilScripts/ 4 | // @version 0.2.1 5 | // @description search through the translated subtitles for specified key words in ZJU classroom(浙江大学智云课堂). Sends alert to you if it appears. if you are using chrome (or Edge with chrome core), allow `media autoplay` in settings in order to hear the alarm. 6 | // @author Shaw Haines 7 | // @license MIT 8 | // @match *://livingroom.cmc.zju.edu.cn/* 9 | // @match *://classroom.zju.edu.cn/* 10 | // @grant none 11 | // @supportURL https://github.com/ShawHaines/evilScripts/ 12 | // @updateURL https://raw.githubusercontent.com/ShawHaines/evilScripts/main/ZJU-Sign-in-ClassRoom-Alert.js 13 | // @run-at document-end 14 | // ==/UserScript== 15 | 16 | (function() { 17 | 'use strict'; 18 | 19 | // Your code here... 20 | class keyWordListener{ 21 | constructor(){ 22 | this.queryString=window.prompt("Input query string","签到"); 23 | this.oldLength=0; 24 | window.setInterval(this.listen.bind(this),1000); // monitor the subtitles every 1000 milisecond. 25 | console.log("Listener initiated."); 26 | }; 27 | listen(){ 28 | if (this.queryString===undefined) return 0; 29 | // FIXME: the class of subtitles in live streaming and playback differ. 30 | let a=document.querySelectorAll(".trans-item,.video-trans-item"); 31 | var newLength=a.length; 32 | if (newLength>this.oldLength){ 33 | for (let i=this.oldLength;i