{"id":100,"date":"2024-12-17T00:36:54","date_gmt":"2024-12-16T16:36:54","guid":{"rendered":"http:\/\/www.luips.com\/?p=100"},"modified":"2024-12-17T00:56:45","modified_gmt":"2024-12-16T16:56:45","slug":"js%e8%b0%83%e8%af%95%e8%bf%87debugger%e5%92%8chook-json%e7%9a%84%e6%96%b9%e5%bc%8f","status":"publish","type":"post","link":"https:\/\/www.luips.com\/index.php\/jinyanjiaocheng\/python\/%e7%88%ac%e8%99%ab\/js%e8%b0%83%e8%af%95%e8%bf%87debugger%e5%92%8chook-json%e7%9a%84%e6%96%b9%e5%bc%8f\/","title":{"rendered":"JS\u8c03\u8bd5\u8fc7debugger\u548cHook JSON\u7684\u65b9\u5f0f"},"content":{"rendered":"<h2>JS\u8c03\u8bd5\u8fc7debugger<\/h2>\n<p>\u4e3b\u8981\u662f\u4e24\u79cd\u65b9\u5f0f\uff1a<br \/>\n1.\u5728\u6d4f\u89c8\u5668\u63a7\u5236\u53f0\uff0c\u627e\u5230debugger\u4ee3\u7801\u4f4d\u7f6e\uff0c\u5728\u6240\u5728\u884c\u5f00\u5934\u76f4\u63a5\u53f3\u952e\uff0c\u70b9\u51fb\u201c\u4e00\u5f8b\u4e0d\u518d\u6b64\u5904\u505c\u6b62\u201d<br \/>\n2.\u9488\u5bf9\u4f7f\u7528\u6784\u9020\u5668constructor\u6267\u884cdebugger\uff0c\u9700\u8981\u901a\u8fc7\u91cd\u5199\u6784\u9020\u5668\u8fc7\u6389debugger\u3002<\/p>\n<pre><code class=\"language-js line-numbers\">let _constructor = constructor;     \/\/let\u5728\u6709\u7684\u6d4f\u89c8\u5668\u4e2d\u53ef\u80fd\u8981\u6362\u6210 var\nFunction.prototype.constructor = function(s) {\n    if ( s== \"debugger\") {\n        console.log(s);\n        return null;\n    }\n    return _constructor(s);\n}\n<\/code><\/pre>\n<p>\u4ee5\u4e0a\u4e24\u79cd\u65b9\u6cd5\u7684\u7ec4\u5408\uff0c\u53ef\u4ee5\u89e3\u51b3 80% \u7684debugger\u95ee\u9898\u3002<br \/>\n\u5269\u4f59\u7684 20% \u9760\u4e2a\u4eba\u80fd\u529b\u548c\u5929\u8d4b\u4e86\u3002<\/p>\n<h2>Hook JSON\u7684\u65b9\u5f0f<\/h2>\n<p>\u4eca\u5929\u5728\u89c2*\u7f51\u7ad9\u4e0a\u4f7f\u7528\u4e0b\u9762\u8fd9\u6bb5\u4ee3\u7801 hook \u7684\u65f6\u5019\uff0c\u53d1\u73b0\u4e86 console.log\u65b9\u6cd5\u6ca1\u6709\u6253\u5370\u65e5\u5fd7\u3002<\/p>\n<pre><code class=\"language-js line-numbers\">\/\/hook\u4ee3\u7801\n(function() {\n    var _stringify = JSON.stringify;\n    JSON.stringify = function(ps) {\n        console.log(\"Hook JSON.stringify \u2014\u2014&gt; \", ps);\n        debugger;\n        return _stringify(ps);  \/\/ \u4e0d\u6539\u53d8\u539f\u6709\u7684\u6267\u884c\u903b\u8f91 \n    }\n})();\n<\/code><\/pre>\n<p>\u4fbf\u731c\u5230\u4e86\uff0c\u4e3a\u4e86\u53cd\u722c\uff0c\u7f51\u7ad9\u7684\u5f00\u53d1\u8005\u5c06 console.log \u65b9\u6cd5\u7981\u7528\u4e86\u3002\u4e8e\u662f\u53ea\u80fd\u8bf7\u51fa\u4e86\u53e6\u4e00\u6bb5\u4ee3\u7801\uff0c\u53ef\u4ee5\u91cd\u65b0\u6253\u5370\u65e5\u5fd7\u3002<\/p>\n<pre><code class=\"language-js line-numbers\">(function(){\n\u3000\u3000var iframe = document.createElement('iframe')\n\u3000\u3000document.body.appendChild(iframe)\n\u3000\u3000window.console = iframe.contentWindow.console\n}())\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>JS\u8c03\u8bd5\u8fc7debugger \u4e3b\u8981\u662f\u4e24\u79cd\u65b9\u5f0f\uff1a 1.\u5728\u6d4f\u89c8\u5668\u63a7&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,11,17],"tags":[],"class_list":["post-100","post","type-post","status-publish","format-standard","hentry","category-js","category-11","category-17"],"_links":{"self":[{"href":"https:\/\/www.luips.com\/index.php\/wp-json\/wp\/v2\/posts\/100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.luips.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.luips.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.luips.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.luips.com\/index.php\/wp-json\/wp\/v2\/comments?post=100"}],"version-history":[{"count":0,"href":"https:\/\/www.luips.com\/index.php\/wp-json\/wp\/v2\/posts\/100\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.luips.com\/index.php\/wp-json\/wp\/v2\/media?parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.luips.com\/index.php\/wp-json\/wp\/v2\/categories?post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.luips.com\/index.php\/wp-json\/wp\/v2\/tags?post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}