细基 發表於 2019-12-11 09:43:00

油猴ajaxhook

<pre><code>// ==UserScript==
// @name         ajaxHook
// @namespace    http://tampermonkey.net/
// @version      0.1
// @descriptiontry 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
         if (~url.indexOf("shopDynamic/allReview")){
               debugger
         }

    }
});

})();
</code></pre>
<p>下面是崔大的</p>
<pre><code>// ==UserScript==
// @name         HookBase64
// @namespace    https://scrape.cuiqingcai.com/
// @version      0.1
// @descriptionHook Base64 encode function
// @author       Germey
// @match       https://scrape.cuiqingcai.com/login1
// @grant      none
// ==/UserScript==
(function () {
    'use strict'
    function hook(object, attr) {
      var func = object
      object = function () {
            console.log('hooked', object, attr)
            var ret = func.apply(object, arguments)
            debugger
            return ret
      }
    }
    hook(window, 'btoa')
})()
</code></pre><br><br>
来源:https://www.cnblogs.com/c-x-a/p/12020679.html
頁: [1]
查看完整版本: 油猴ajaxhook