百度劫持分享码上传修改
// ==UserScript==
// @name 百度劫持分享码上传修改
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://pan.baidu.com/*
// @icon https://www.google.com/s2/favicons?domain=baidu.com
// @grant none
// ==/UserScript==
// ==UserScript==
// @name XmlhttpRequest Hook
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://bbs.tampermonkey.net.cn/*
// @grant none
// ==/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
for( i = 0; i < XMLHttpRequest.callbacks.length; i++ ) {
XMLHttpRequest.callbacks[i]( this );
}
// call the native send()
if(arguments.length!==0){
if(arguments[0]!==null&&arguments[0].indexOf!==undefined){
if(arguments[0].indexOf('pwd')!==-1&&arguments[0].indexOf('vcode')===-1){
var number=prompt("输入默认修改的四位分享码,默认:8888","8888")
if(number.length!==4)
{
number='8888'
}
arguments[0]=arguments[0].replace(/pwd=[a-zA-Z0-9]{0,4}&/i,"pwd="+number+"&")
}
}
}
console.log('arguments',arguments)
oldSend.apply(this, arguments);
}
}
}
// e.g.
addXMLRequestCallback( function( xhr ) {
xhr.addEventListener("load", function(){
if ( xhr.readyState == 4 && xhr.status == 200 ) {
console.log( xhr.responseURL );
}
});
});