腳本已歸檔
該腳本已經被作者歸檔,腳本可能失效並且作者不再維護,你無法再進行問題反饋。
// ==UserScript==
// @name 亿学宝秒杀答案
// @namespace http://tampermonkey.net/
// @version 0.2
// @description try to take over the world!
// @author You
// @match https://lnyy.yxbyun.com/newnorthstu*
// @icon https://www.google.com/s2/favicons?domain=yxbyun.com
// @grant none
// @run-at document-start
// ==/UserScript==
function addXMLRequestCallback(callback){
var oldSend, i;
if( XMLHttpRequest.callbacks ) {
// we've already overridden send() so just add the callback
XMLHttpRequest.callbacks.push( callback );
} else {
// create a callback queue
XMLHttpRequest.callbacks = [callback];
// store the native send()
oldSend = XMLHttpRequest.prototype.send;
// override the native send()
XMLHttpRequest.prototype.send = function(){
// process the callback queue
// the xhr instance is passed into each callback but seems pretty useless
// you can't tell what its destination is or call abort() without an error
// so only really good for logging that a request has happened
// I could be wrong, I hope so...
// EDIT: I suppose you could override the onreadystatechange handler though
console.log('劫持了')
for( i = 0; i < XMLHttpRequest.callbacks.length; i++ ) {
XMLHttpRequest.callbacks[i]( this,arguments );
}
// call the native send()
oldSend.apply(this, arguments);
}
}
}
// e.g.
addXMLRequestCallback( function( xhr,test ) {
xhr.addEventListener("load", function(){
if ( xhr.readyState == 4 && xhr.status == 200 ) {
if(xhr.responseURL.indexOf("yxbstudent/studentWeb/toIndex")!=-1){
if(test.length>0&&test[0].indexOf("getWorkPaperInfo")!=-1){
console.log( xhr,test );
let obj=JSON.parse(xhr.response)
let settext=""
obj.data.questionList.forEach((item)=>{
settext+=item.content.correct+"</br>-----------------------------------------</br>"
})
settext+='<span style="color:red;font-size:19px">出处油猴中文网bbs.tampermonkey.net.cn 作者:李恒道</span>'
let div=document.createElement("div");
div.innerHTML=settext;
document.querySelector('.test_main').prepend(div)
}
}
}
});
});