Last active
August 29, 2015 14:00
-
-
Save lo48576/0cb6d181cec0eb4c1fe8 to your computer and use it in GitHub Desktop.
auto login scripts for TokyoTech Portal and titech-pubnet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
titech-automatrix-bookmarklet.js : ブックマークレット用にちょっとだけ最適化したコード | |
titech-automatrix.user.js : FirefoxのGreasemonkey用ユーザスクリプト | |
使い方: | |
Greasemonkey用のは使える人はわかるだろうし省略。 | |
お気に入りに登録して使うブックマークレット用のは、 | |
javascript:(function(d,j,i,p,m){var l=d.login,f=d.getElementsByTagName('input'),t,c;switch(location.search.replace(/[&?]Template=([^&]*)(&.*)?/,'$1')){case "userpass_key":l.usr_name.value=i;l.usr_password.value=p;l.submit();break;case "idg_key":while(j++<3){t=f.item(j);c=t.parentNode.parentNode.getElementsByTagName('th')[0].innerHTML;t.value=m[c.match(/[1-7]/)[0].charCodeAt(0)-'1'.charCodeAt(0)].charAt(c.match(/[A-J]/)[0].charCodeAt(0)-'A'.charCodeAt(0));}l.submit();break;default:location.href='http://portal.titech.ac.jp/';}})(document,0,'14X99999','password1234',["1111111111","2222222222","3333333333","4444444444","5555555555","6666666666","7777777777"]); | |
これの最後らへんの「14X99999」「password1234」それから111…から777…までを、それぞれID、パスワード、認証用の表に書き換えてください。 | |
そしてそれを、ブックマークのurlとして登録します。 | |
使い方の詳細な説明は http://l1048576.blogspot.com/2014/05/titech-automatrix1.html を参照。 | |
このブックマークレットは、 | |
・titech-pubnetのログイン画面でクリックすると、自動入力+自動送信、 | |
・「同意(マトリクス認証)」をクリックした直後のページでクリックすると、自動入力+自動送信、 | |
・その後の「Matrix Authentication」のページでクリックすると、適切に自動入力+自動送信でログイン完了、 | |
・これら以外の普通のページからこのブックマークをクリックすると東工大ポータルのページにジャンプ、 | |
といった挙動をします。 | |
要は普通のブックマークとしても使えて、ログインページではワンクリックで次のページに進める便利なスクリプトです。 | |
FirefoxのGreasemonkey用の方はノークリックでログインできるので、Firefox使ってるならそちらをお勧めしときます。 | |
動作確認: | |
Firefox 28.0 (on linux, Windows XP SP3) | |
Firefox 29.0 (on linux, Windows XP SP3) | |
Google Chrome 34.0.1847.132 (on linux) | |
Google Chrome 33.0.1750.154 m (on Windows XP SP3) | |
Google Chrome 34.0.1847.131 m (on Windows XP SP3) | |
IEですか?俺オフラインのWindowsXPしか持ってないんで今度学校で確認しときますわ | |
追記: | |
Internet Explorer 8.0.6001.18702 (on Windows XP SP3) | |
でも正常な動作を確認しました。 | |
しましたが、もう誰も使ってないはずですね… |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//d: document | |
//n: location | |
//j: iterator | |
//i: id | |
//p: password | |
//m: matrix | |
//l: document.login | |
//c: coords_str.match | |
//f: input form | |
//t: target form | |
(function(d,n,j,i,p,m){ | |
var l=d.login,f=d.getElementsByTagName('input'),t,c; | |
switch(n.search.replace(/[&?]Template=([^&]*)(&.*)?/,'$1')) { | |
case 'userpass_key': | |
l.usr_name.value=i; | |
l.usr_password.value=p; | |
l.submit(); | |
break; | |
case 'idg_key': | |
// you can use also `while(++j<4){` but you must escape '<' to '<' when you use the code in html. | |
while(++j-4){ | |
t=f.item(j);c=t.parentNode.parentNode.getElementsByTagName('th')[0].innerHTML; | |
t.value=m[c.match(/[1-7]/)[0].charCodeAt(0)-'1'.charCodeAt(0)].charAt(c.match(/[A-J]/)[0].charCodeAt(0)-'A'.charCodeAt(0)); | |
} | |
l.submit(); | |
break; | |
default: | |
if(n.host+n.pathname == 'wlanauth.noc.titech.ac.jp/fs/customwebauth/login.html') { | |
d.getElementById('username').value=i; | |
d.getElementById('password').value=p; | |
submitAction(); | |
} else { | |
n.href = 'http://portal.titech.ac.jp/'; | |
} | |
} | |
})(document,location,0,'14X99999','password1234',['1111111111','2222222222','3333333333','4444444444','5555555555','6666666666','7777777777']); | |
// one-liner: | |
//(function(d,n,j,i,p,m){var l=d.login,f=d.getElementsByTagName('input'),t,c;switch(n.search.replace(/[&?]Template=([^&]*)(&.*)?/,'$1')){case 'userpass_key':l.usr_name.value=i;l.usr_password.value=p;l.submit();break;case 'idg_key':while(++j-4){t=f.item(j);c=t.parentNode.parentNode.getElementsByTagName('th')[0].innerHTML;t.value=m[c.match(/[1-7]/)[0].charCodeAt(0)-'1'.charCodeAt(0)][c.match(/[A-J]/)[0].charCodeAt(0)-'A'.charCodeAt(0)];}l.submit();break;default:if(n.host+n.pathname=='wlanauth.noc.titech.ac.jp/fs/customwebauth/login.html'){d.getElementById('username').value=i;d.getElementById('password').value=p;submitAction();}else{n.href='http://portal.titech.ac.jp/';}}})(document,location,0,'14X99999','password1234',['1111111111','2222222222','3333333333','4444444444','5555555555','6666666666','7777777777']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==userscript== | |
// @name Titech-AutoMatrix | |
// @namespace | |
// @include https://portal.nap.gsic.titech.ac.jp/GetAccess/Login?* | |
// @include https://wlanauth.noc.titech.ac.jp/fs/customwebauth/login.html?* | |
// @author Larry <nu11p0.6477@gmail.com> | |
// @description Pass authentication (with password and matrix) automatically in Titech portal. | |
// @version 1.1 | |
// ==/UserScript== | |
(function(d,n,id,password,matrix){ | |
// match() returns array of strings, so match(foo)[1] may be error if there's no match. | |
//var authmode = n.search.match(/[&?]Template=([^&]*)(&.*)?/)[1]; | |
var authmode = n.search.replace(/[&?]Template=([^&]*)(&.*)?/,'$1'); | |
switch(authmode) { | |
case "userpass_key": | |
d.login.usr_name.value = id; | |
d.login.usr_password.value = password; | |
d.login.submit(); | |
break; | |
case "idg_key": | |
var A_charcode = 'A'.charCodeAt(0); | |
var One_charcode = '1'.charCodeAt(0); | |
// for detail, see script in login page. | |
var input_form = d.getElementsByTagName('input'); | |
//for(var i=1; i<=3; ++i) { | |
for(var i=1; i<4; ++i) { | |
// target form | |
var target = input_form.item(i); | |
// coordinates in string (e.g. [B,4]) | |
// also you can use target.parentNode.parentNode.getElementsByTagName('th')[0].innerHTML; | |
var coords_str = target.parentNode.parentNode.getElementsByTagName('th')[0].firstChild.nodeValue; | |
// for example, if coords_str == '[B,4]', get matrix[3][1] | |
// if coords_str == '[A,1]', get matrix[0][0] | |
// if coords_str == '[A,7]', get matrix[6][0] | |
//var character = matrix[coords_str.match(/[1-7]/)[0].charCodeAt(0)-One_charcode][coords_str.match(/[A-J]/)[0].charCodeAt(0)-A_charcode]; | |
// matrix[foo][bar] evaluates to undefined in IE8!!! FUUUUUUUUUUUUUUU*K!!!!! | |
// it's because you must use matrix[foo].charAt(bar) . | |
var character = matrix[coords_str.match(/[1-7]/)[0].charCodeAt(0)-One_charcode].charAt(coords_str.match(/[A-J]/)[0].charCodeAt(0)-A_charcode); | |
target.value = character; | |
} | |
d.login.submit(); | |
break; | |
default: | |
if(n.host+n.pathname == 'wlanauth.noc.titech.ac.jp/fs/customwebauth/login.html') { | |
d.getElementById('username').value=id; | |
d.getElementById('password').value=password; | |
// submitAction() is defined in login.html | |
submitAction(); | |
} | |
} | |
})(document,location,'14X99999','password1234', | |
["1111111111", | |
"2222222222", | |
"3333333333", | |
"4444444444", | |
"5555555555", | |
"6666666666", | |
"7777777777"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment