Skip to content

Instantly share code, notes, and snippets.

@singleghost
Created May 29, 2016 15:58
Show Gist options
  • Save singleghost/dafa9d72e64fa75f3e77ad13a8c2a320 to your computer and use it in GitHub Desktop.
Save singleghost/dafa9d72e64fa75f3e77ad13a8c2a320 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name 体测程序查询(根据学号)
// @namespace tyys
// @description 公体部的锅
// @include http://www.tyys.zju.edu.cn:8080/hyz/*
// @version 1
// @grant none
// ==/UserScript==
function createSearchArea() {
sidebar = document.getElementById("catalog-tree");
searchText = document.createElement("input");
sidebar.appendChild(searchText);
btn = document.createElement("button");
btn.type = "button";
btn.innerHTML = "search";
btn.onclick = function() {
url = "/hyz/collectresult?xh=" + searchText.value;
document.getElementsByTagName("iframe")[1].src = url;
}
sidebar.appendChild(btn);
}
function autoFillcaptcha() {
console.log("auto fill captcha");
x = new XMLHttpRequest();
x.open("GET", "http://www.tyys.zju.edu.cn:8080/hyz/userfiles/image/test.jsp", false);
x.send();
document.getElementById("yzm").value = x.responseText;
}
function allinOne() {
if (window.location.pathname == "/hyz/indexphone.jsp") {
autoFillcaptcha();
} else if(window.location.pathname == "/hyz/index") {
console.log("create search area");
createSearchArea();
}
}
window.onload = allinOne;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment