Skip to content

Instantly share code, notes, and snippets.

@summivox
Created May 23, 2012 15:36
Show Gist options
  • Save summivox/2775950 to your computer and use it in GitHub Desktop.
Save summivox/2775950 to your computer and use it in GitHub Desktop.
清华评教:默认选优秀
// ==UserScript==
// @name thu-pingjiao
// @namespace http://github.com/smilekzs
// @include http*://zhjw.cic.tsinghua.edu.cn/pj.xspj_cpryb.do*
// @version 0.2
// ==/UserScript==
injectScript=function(src){
var scriptEl;
scriptEl = document.createElement('script');
scriptEl.innerHTML = "(" + (src.toString()) + ")();";
return document.head.appendChild(scriptEl);
};
injectScript(function(){
var d=document;//centerFrame.cpzbframe.document;
var x=d.getElementsByTagName('input');
var exp=/优秀/;
for(i in x) if(x[i].type==='radio') if(exp.exec(x[i].nextSibling.data)) x[i].checked=true;
var el=document.createElement('input');
el.type='button';
el.value='提了个交';
el.onclick=function(){window.sjqd();};
var frm=document.getElementsByName('frm')[0];
frm.insertBefore(el, frm.firstElementChild);
});
@zzz6519003
Copy link

for(i in x) if(x[i].type==='radio') if(exp.exec(x[i].nextSibling.data)) x[i].checked=true;

是啥意思~

@summivox
Copy link
Author

summivox commented Dec 9, 2013

@zzz6519003 对于所有,如果后面跟着“优秀”文字,就选中。
这是一年前写的啦,现在想这么写不是很科学哇,[].slice.call(d.querySelectorAll('input[type=radio]').forEach更简单

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment