Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加SSLVPN模式 #26

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ module.exports = (grunt) ->
// @include *.cic.tsinghua.edu.cn/syxk.vsyxkKcapb.do*
// @include *.cic.tsinghua.edu.cn/xkBks.vxkBksXkbBs.do*
// @include *.cic.tsinghua.edu.cn/xkYjs.vxkYjsXkbBs.do*
// @include https://sslvpn.tsinghua.edu.cn:*/syxk.vsyxkKcapb.do*
// @include https://sslvpn.tsinghua.edu.cn:*/xkBks.vxkBksXkbBs.do?m=kbSearch*
// @include https://sslvpn.tsinghua.edu.cn:*/xkYjs.vxkYjsXkbBs.do?m=kbSearch*
// @include https://sslvpn.tsinghua.edu.cn/,DanaInfo=zhjwxk.cic.tsinghua.edu.cn+syxk.vsyxkKcapb.do*
// @include https://sslvpn.tsinghua.edu.cn/,DanaInfo=zhjwxk.cic.tsinghua.edu.cn+xkBks.vxkBksXkbBs.do?m=kbSearch*
// @include https://sslvpn.tsinghua.edu.cn/,DanaInfo=zhjwxk.cic.tsinghua.edu.cn+xkYjs.vxkYjsXkbBs.do?m=kbSearch*
// @grant GM_xmlhttpRequest
// ==/UserScript==

//#include
Expand Down
154 changes: 110 additions & 44 deletions dist/thucal2.user.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/FileSaver.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion src/thucal2.iced
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,6 @@ unsafeWindow.thucal=thucal=new ->
@ui.log=(s)->@status.append(s+'\n')

## params

if document.location.toString().match(/Yjs/)
@params=
listUrl: 'http://zhjw.cic.tsinghua.edu.cn/jxmh.do'
Expand All @@ -461,6 +460,11 @@ unsafeWindow.thucal=thucal=new ->
listVerb: 'bks_jxrl_all'
listRole: 'bks'

if document.location.toString().match(/sslvpn/)
@params.listUrl="https://sslvpn.tsinghua.edu.cn:11001/jxmh.do"



@make=->
@ui.log "******THUCAL2******"
termIdP=parseTermId($('input[name=p_xnxq]').val())
Expand All @@ -470,6 +474,29 @@ unsafeWindow.thucal=thucal=new ->
@ui.log '不支持小学期!'
return

if document.location.toString().match(/sslvpn/)
@ui.log "SSLVPN 模式: 自动登录info..."
#open info page (to utilize sslvpn system's auto-login feature)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very clever...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know I'm stupid, it's for testing only at that time!

let's change that to document.location.host.match ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不我是说居然可以自动login,这比不用sslvpn还牛逼……

可以location.host,也可以/sslvpn/.test(不需要强制转换location)
regex本身不是问题,因为你greasemonkey header已经限制过location了

另外我当时的style太差,你看着不顺眼就修好了……
我现在的话应该会用webpack + livescript写,不过这个项目你也知道我早就不管了……

await GM_xmlhttpRequest {
url: "https://sslvpn.tsinghua.edu.cn/dana/home/launch.cgi?url=http%3A%2F%2Finfo.tsinghua.edu.cn"
method: 'GET'
onload: defer(page1)
onerror: (err)->
thucal.ui.log "Warning: SSLVPN Preparation Error (info page)..."
}

@ui.log "SSLVPN 模式: 准备导出页面"
#open LIST page (to ensure jxmh.do is binded to port 11001?)
await GM_xmlhttpRequest {
url: "https://sslvpn.tsinghua.edu.cn/dana/home/launch.cgi?url=http%3A%2F%2Fzhjw.cic.tsinghua.edu.cn%2Fjxmh.do%3Fm%3Dbks_jxrl_all"
method: 'GET'
garbage: page1
onload: defer(page2)
onerror: (err)->
thucal.ui.log "Warning: SSLVPN Preparation Error (listing page)..."
}
#console.log(page2.finalUrl) #### No way to get the redurected URL (opened port); our best guess is 11001...

await get_L defer(Lraw)
@ui.log 'list完成'

Expand Down