油猴ajaxhook

// ==UserScript==
// @name         ajaxHook
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        http://www.dianping.com/ajax/json/shopDynamic/allReview*
// @require       http://cdn.bootcss.com/jquery/3.1.0/jquery.min.js
// @require       https://unpkg.com/ajax-hook/dist/ajaxhook.min.js
// @include       http://www.dianping.com/shop/*
// @exclude       http://diveintogreasemonkey.org/*
// @exclude       http://www.diveintogreasemonkey.org/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

  hookAjax({
    onreadystatechange: function(xhr) {

    },
    onload: function(xhr) {
    let close_btn = $(".J-bonus-close")
       console.log("????")
       if(close_btn){
                  close_btn.click();
       }
        let url=xhr.responseURL
        if (~url.indexOf("shopDynamic/allReview")){
                //debugger
                console.log("url",decodeURIComponent(xhr.responseURL))
                console.log("text",xhr.responseText);
        }

                //do something!

    },
    //拦截函数
    open:function(arg){
          let url=arg[1]
           if (~url.indexOf("shopDynamic/allReview")){
                 debugger
         }

    }
  });

})();

下面是崔大的

// ==UserScript==
// @name         HookBase64
// @namespace    https://scrape.cuiqingcai.com/
// @version      0.1
// @description  Hook Base64 encode function
// @author       Germey
// @match       https://scrape.cuiqingcai.com/login1
// @grant        none
// ==/UserScript==
(function () {
    'use strict'
    function hook(object, attr) {
        var func = object[attr]
        object[attr] = function () {
            console.log('hooked', object, attr)
            var ret = func.apply(object, arguments)
            debugger
            return ret
        }
    }
    hook(window, 'btoa')
})()
posted @ 2019-12-11 09:43  公众号python学习开发  阅读(2403)  评论(0编辑  收藏  举报