Skip to content

Instantly share code, notes, and snippets.

@sublee
Last active October 10, 2015 18:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sublee/3736189 to your computer and use it in GitHub Desktop.
Save sublee/3736189 to your computer and use it in GitHub Desktop.
WebOffice Login for Google Chrome
// ==UserScript==
// @name WebOffice Login for Google Chrome
// @version 0.0.1
// @namespace https://gist.github.com/3736189
// @description Makes WebOffice to be worked on Google Chrome.
// @match http://hr.weboffice.co.kr/main/jsp/login.jsp
// @match http://hr.weboffice.co.kr/tam/tm_attend/tm_attend*
// @copyright 2012, Heungsub Lee <sub@nexon.co.kr>
// @license Public Domain
// ==/UserScript==
var fn = function() {
// patch XSheet parser
var _makeXSheetWithXmlText = window.makeXSheetWithXmlText;
window.makeXSheetWithXmlText = function(xmlText, mode) {
var try_these = Try.these;
Try.these = function() {
var xdom = {};
xdom.loadXML = function(xml) {
this.__proto__ = (new DOMParser()).parseFromString(xml, 'text/xml');
window.xdom = this;
if (this.documentElement.nodeName == 'parsererror') {
this.parseError = {errorCode: 1};
} else {
this.parseError = {errorCode: 0};
}
};
return xdom;
};
var result = _makeXSheetWithXmlText(xmlText, mode);
Try.these = try_these;
return result;
};
// methods for XmlSheet, XMLDocument
XmlSheet.prototype.EtcData = function(key) {
var etcs = this.xdom.documentElement.getElementsByTagName('ETC');
var result = null;
$A(etcs).each(function(e) {
if (e.getAttribute('KEY') == key) {
result = e.childNodes[0].data;
return false;
}
});
return result;
};
XMLDocument.prototype.selectNodes = function(xpath) {
var ns_resolver = this.createNSResolver(this.documentElement);
var result = document.evaluate(xpath, this.documentElement, ns_resolver,
XPathResult.ORDERED_NODE_SNAPSHOT_TYPE);
var nodes = [];
for (var i = 0; i < result.snapshotLength; ++i) {
nodes.push(result.snapshotItem(i));
}
return nodes;
};
XMLDocument.prototype.selectSingleNode = function(xpath) {
var nodes = this.selectNodes(xpath);
if (nodes.length) {
return nodes[0];
}
return null;
};
// run InitPage again
document.forms[0].document = document.forms[0];
InitPage();
};
var e = document.createElement('script');
e.innerHTML = '(' + fn.toString() + ')();';
var scripts = document.head.getElementsByTagName('script');
var target = scripts[scripts.length - 1];
target.parentNode.insertBefore(e, target);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment