Last active
December 24, 2017 13:40
-
-
Save Yexiaoxing/a8a23c1a626b8112db2698df6bd01640 to your computer and use it in GitHub Desktop.
CUHK-Shenzhen Course Registration VCode OCR, Byebye!
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 Ultra OCR for CUHKSZ Course Reg. | |
// @namespace http://example.com/ | |
// @version 0.2 | |
// @description try to take over the world! | |
// @author You | |
// @match http://course.computercomity.com:81/psc/csprd/EMPLOYEE/HRMS/c/SA_LEARNER_SERVICES.* | |
// @match http://116.31.95.2:81/psc/csprd/EMPLOYEE/HRMS/c/SA_LEARNER_SERVICES.* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
window.onload = function () { | |
net2.ContentLoader.prototype.loadXMLDoc = function(bParamsDone) { | |
if (typeof ptConsole2 != 'undefined' && ptConsole2 && ptConsole2.isActive() && bPerf) | |
ptConsole2.append((new Date()).valueOf() + " processPIAPostParams start"); | |
if (typeof bParamsDone == 'undefined' || !bParamsDone) { | |
if (!this.processPIAPostParams()) | |
return; | |
} | |
this.SetInProcess(true, this.form); | |
if (typeof ptConsole2 != 'undefined' && ptConsole2 && ptConsole2.isActive() && bPerf) | |
ptConsole2.append((new Date()).valueOf() + " processPIAPostParams end and server start"); | |
if (this.method.indexOf("GET") != -1 && this.params.length > 0) | |
this.url += "?" + this.params; | |
if (typeof ptConsole2 != 'undefined' && ptConsole2 && ptConsole2.isActive() && !bPerf) | |
ptConsole2.append((new Date()).valueOf() + " url:\n" + this.url + "\nparams:" + this.params.length + "\n" + this.params); | |
try { | |
this.req = this.createXMLHTTPRequest(); | |
} catch (e) { | |
alert(e); | |
this.SetInProcess(false); | |
this.SetWaitingObject(null, "", null, false, false); | |
this.onerror.call(this); | |
} | |
if (this.req) { | |
try { | |
var loader = this; | |
this.req.onreadystatechange = function() { | |
loader.onReadyState.call(loader); | |
console.log('k'); | |
ocr(); | |
}; | |
if (browserInfoObj2.isSafari2x) { | |
this.isAsync = false; | |
} | |
this.req.open(this.method, this.url, this.isAsync); | |
if (this.isAsync && typeof this.req.withCredentials != 'undefined') | |
this.req.withCredentials = "true"; | |
if (this.contentType) { | |
this.req.setRequestHeader('Content-Type', this.contentType); | |
} | |
if (this.headerArray) { | |
for (var i = 0; i < this.headerArray.length; i++) { | |
if (this.headerArray[i][0] && this.headerArray[i][1]) | |
this.req.setRequestHeader(this.headerArray[i][0], this.headerArray[i][1]); | |
} | |
} | |
nLastAction = 1; | |
if (!this.bPrompt && typeof nResubmit != 'undefined' && !this.bCallBack) | |
nResubmit++; | |
this.req.send(this.params); | |
} catch (err) { | |
try { | |
if (!this.isAsync && ((this.url).indexOf(net2.EXCLUDEPORTALURL) > -1)) { | |
} else | |
alert("Error in opening/sending request: - Error: " + err + " - Url:" + this.url + ", - URL Parameters: " + this.params); | |
} catch (e) { | |
alert("Error in opening/sending request url: " + this.url + ", URL Param: " + this.params); | |
} | |
this.sendErrorHandler(); | |
return; | |
} | |
} | |
}; | |
window.ocr = function () { | |
var input = document.getElementById('inputValue'); | |
if (!input) return; | |
input.value = window.VCD; | |
console.log("OCR Result: " + window.VCD); | |
input.hidden = true; | |
checkUserName(window.VCD); | |
var byebye_code = document.getElementById('imgCaptcha'); | |
byebye_code.src = "http://course.computercomity.com:81/vcode.png?randval=BYE_BYE"; | |
console.log("Byebye VCode!"); | |
}; | |
ocr(); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment