中国大学mooc数据劫持高清
// ==UserScript==
// @name 中国大学mooc数据劫持高清
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.icourse163.org/learn/*
// @icon https://www.google.com/s2/favicons?domain=undefined.
// @grant none
// ==/UserScript==
var oldxhr=window.XMLHttpRequest
function newobj(){}
window.XMLHttpRequest=function(){
let tagetobk=new newobj();
tagetobk.oldxhr=new oldxhr();
let handle={
get: function(target, prop, receiver) {
if(prop==='oldxhr'){
return Reflect.get(target,prop);
}
if(typeof Reflect.get(target.oldxhr,prop)==='function')
{
if(Reflect.get(target.oldxhr,prop+'proxy')===undefined)
{
target.oldxhr[prop+'proxy']=new Proxy(Reflect.get(target.oldxhr,prop), {
apply: function(target, thisArg, argumentsList) {
return Reflect.apply(target, thisArg.oldxhr, argumentsList);
}
});
}
return Reflect.get(target.oldxhr,prop+'proxy')
}
if(prop.indexOf('response')!==-1)
{
let result=Reflect.get(target.oldxhr,prop)
if(target.oldxhr.responseURL.indexOf('/v1/vod/video?videoId=')!==-1&&result.indexOf!==undefined&&result.indexOf('videoUrl')!==-1&&result.indexOf('quality')!==-1){
let jstext=JSON.parse(result)
if(jstext.result!==undefined&&jstext.result.videos!==undefined){
let fucktext=[]
let main={
url:'',
quality:-999
}
for(let index=0;index<jstext.result.videos.length;index++){
let item=jstext.result.videos[index]
console.log('item',item.quality,main.quality)
if(item.quality>main.quality){
main.quality=item.quality
main.url=item.videoUrl
}
}
console.log('main',main)
for(let index=0;index<jstext.result.videos.length;index++){
let item=jstext.result.videos[index]
if(item.videoUrl!==main.url){
console.log('replace',item.videoUrl,main.url)
result=result.replace(item.videoUrl,main.url)
}
}
console.log('result1',result)
return result
}
}
return result
}
return Reflect.get(target.oldxhr,prop);
},
set(target, prop, value) {
return Reflect.set(target.oldxhr, prop, value);
},
has(target, key) {
debugger;
return Reflect.has(target.oldxhr,key);
}
}
let ret = new Proxy(tagetobk, handle);
return ret;
}