Skip to content

Instantly share code, notes, and snippets.

@castor4bit
Created November 22, 2012 07:02
Show Gist options
  • Save castor4bit/4129759 to your computer and use it in GitHub Desktop.
Save castor4bit/4129759 to your computer and use it in GitHub Desktop.
CybouzuAutoLogon
// ==UserScript==
// @name CybouzuAutoLogon
// @namespace http://cbz.example.co.jp/
// @include http://cbz.example.co.jp/cgi-bin/ag.cgi
// @include http://cbz.example.co.jp/cgi-bin/ag.cgi?page=AGIndex
// ==/UserScript==
(function() {
var member_id = 00000;
var member_name = 'member_name';
var check = 0;
document = window.document;
var sel_id = document.evaluate('//select[@name="_ID"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (sel_id.singleNodeValue) {
var len = sel_id.singleNodeValue.options.length;
for (var i=0; i<len; ++i) {console.log(sel_id.singleNodeValue.options[i].value);
if (sel_id.singleNodeValue.options[i].value == member_id) {
sel_id.singleNodeValue.selectedIndex = i;
check++;
}
}
}
var input_passwd = document.evaluate('//input[@name="Password"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (input_passwd.singleNodeValue) {
input_passwd.singleNodeValue.value = member_name;
check++;
}
if (check >= 2) {
var form = document.evaluate('//form[@name="LoginForm"]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
if (form.singleNodeValue) {
form.singleNodeValue.submit();
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment