js hook XMLHttpRequest

 

var code2 = function(){
var open = window.XMLHttpRequest.prototype.open;
window.XMLHttpRequest.prototype.open = function (method, url, async){
    if (url.indexOf("nUdYJ1Ji")>-1){
        debugger;
    }
    return open.apply(this, arguments);
};
};
var script = document.createElement('script');
script.textContent = '(' + code2 + ')()';
(document.head||document.documentElement).appendChild(script);
script.parentNode.removeChild(script);

 

 

 

 

 

 

// ==UserScript==
// @name         xhr_setRequestHeader
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://ppzh.jd.com/octopusbrandweb/brand/view/search/rankLocationNew.html
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
  'use strict';
  let org = window.XMLHttpRequest.prototype.setRequestHeader;
  window.XMLHttpRequest.prototype.setRequestHeader = function(key,value){
    let keyToLocaleLowerCase = key.toLocaleLowerCase();
    console.log(keyToLocaleLowerCase, value)
    if(keyToLocaleLowerCase.indexOf('sign') !== -1){
      debugger;
    }
    return org.apply(this,arguments);
  }
})();

 

posted @ 2023-06-08 12:52  AngDH  阅读(204)  评论(0编辑  收藏  举报