JSON Viewer

格式化显示JSON使数据看起来更加漂亮,支持折叠/展开格式化后的数据,支持JSON脑图让调用层级看着更清晰,支持复制JSON脑图节点路径

目前為 2024-10-14 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name JSON Viewer
  3. // @namespace http://tampermonkey.net/
  4. // @version v0.6.7
  5. // @author Feny
  6. // @description 格式化显示JSON使数据看起来更加漂亮,支持折叠/展开格式化后的数据,支持JSON脑图让调用层级看着更清晰,支持复制JSON脑图节点路径
  7. // @icon data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEAeAB4AAD/4QAiRXhpZgAATU0AKgAAAAgAAQESAAMAAAABAAEAAAAAAAD/2wBDAAIBAQIBAQICAgICAgICAwUDAwMDAwYEBAMFBwYHBwcGBwcICQsJCAgKCAcHCg0KCgsMDAwMBwkODw0MDgsMDAz/2wBDAQICAgMDAwYDAwYMCAcIDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAz/wAARCAAgACADASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD9wvjF8bLX4ZrHZx+XNqlwnmKjH5YUyRvb6kEAd8H058d1b47XV5Ir3eoN++bagaXYrN6KOBn2FfPPx5/aEutX8a+KNWhIubhruZLSNj8u1WMcIOP4QoXOOwNS/wDBM79lDTfjh8YNe+IXj63TxRdeHfKjsE1KMTxtdSbmMmxvlAiVV2IBsUybgAyKR9ZTy6lhsM69Xovm2+iPmKmOqYjEKjT6v5WXU9e8beKrjxZpp/s/xFrfhjWIwWs9X0q42z2kmPlZo2zDcxjqYZ0eNv7obDDf/YL/AG8L745eJNc+G3xCttP0n4qeEWZZ2sVZNP8AENsu0rd2ysS0ZKPG7RMSQsisCcukWd+3x4RtfhpqGk+JNPjS0g1mV7a8iT5UM4XesgHYsofdjglQepJPxwPE1x4V/au8LePtNkeK40ma0lmdDgyorvHMhPo9uxjP+y1bUcHRxmGbS1adn1TXT0/4fcipiqmExCi3pfVdGn19f+GLni/w7ceGf2wPFXga+Vo5rW/vDbI3WWI/v4HA/wBqBg3tk+lfWX7AXia1+F/iDV9B1CRbWHXjFLayyHannpuUxk+rqy4zxlMdWAPQft7fsL33x91nQfiD4DutP0r4oeDXVrT7cWWx1y3UsTZ3LKCyAh5FEigkLLIpHzBk5vwj4JuvE2kLJfeHdY8N6lGAl5pepwBZrOT+JRIuYp0ByBNCzxPg4bIICqYyljMKot62Sa6prr6P/gBDC1MLiHJLS90+jT6ev/Dnmn/BVP8Aaw0nxv4/8P8Aw18KXK69qmk3MlxqEdiRMwuivlpbrtPLopkMnZNy5IIYLyPwa/Z8vvEmv+HtHu4/Ovr+5iS6KDcqAtukwe6om7nuEJxX0XoH7PK/bJG0vRoY5rr/AFslvbLGZf8AfcAf+PGvafgv8CbX4byNqFyI5tWmXYCoytsh6qvqx7t+A4yWiWYUsLhlRpbr72318kVHA1MTiHVqbP7kl0P/2Q==
  8. // @homepage https://github.com/xFeny/monkey-jsonviewer
  9. // @match *://*/*
  10. // @require https://unpkg.com/dom-to-image@2.6.0/dist/dom-to-image.min.js
  11. // @require https://unpkg.com/jquery@3.7.1/dist/jquery.min.js
  12. // @require data:application/javascript,%3Bwindow.jQuery%3DjQuery%3B%3Bwindow.jquery%3DjQuery%3B
  13. // @require https://unpkg.com/jsmind@0.8.5/es6/jsmind.js
  14. // @require data:application/javascript,%3Bwindow.jsMind%3DjsMind%3Bwindow.jsmind%3DjsMind%3B
  15. // @require https://unpkg.com/jsmind@0.8.5/es6/jsmind.screenshot.js
  16. // @require https://unpkg.com/systemjs@6.15.1/dist/system.min.js
  17. // @require https://unpkg.com/systemjs@6.15.1/dist/extras/named-register.min.js
  18. // @require data:application/javascript,%3B(typeof%20System!%3D'undefined')%26%26(System%3Dnew%20System.constructor())%3B
  19. // @resource jsmind https://unpkg.com/jsmind@0.8.5/style/jsmind.css
  20. // @grant GM_addStyle
  21. // @grant GM_getResourceText
  22. // @grant GM_getValue
  23. // @grant GM_setClipboard
  24. // @grant GM_setValue
  25. // @grant unsafeWindow
  26. // @note v0.6.6 增加多一种暗黑主题,默认主题色修改
  27. // @note v0.6.3 修复暗黑主题,tab颜色问题
  28. // @note v0.6.2 脑图增加JSON Crack
  29. // @note v0.6.1 增加多一种浅色主题
  30. // @note v0.6.0 增加简单HTTP 请求功能,可请求GET/POST/PUT/DELETE的API接口,而不单单只能GET请求使用
  31. // @note v0.5.9 jsonp格式小优化
  32. // @note v0.5.8 增加JSON手动输入
  33. // @note v0.5.7 一些小细节优化
  34. // @note v0.5.6 修复BUG
  35. // @note v0.5.5 解决@require jquery-simple-tree-table.min.js依赖加载失败问题
  36. // @note v0.5.4 单击复制修改为CTRL+单击复制JSONPath功能,JSON格式化风格增加table格式
  37. // @note v0.5.3 增加暗黑主题色
  38. // @note v0.5.2 单击JSON格式化的key可复制JSONPath
  39. // @note v0.5.1 修复JSONPath提示有误
  40. // @note v0.5.0 解决chrome 120+以上内核JSON格式化不执行和引入layer报错问题
  41. // @note v0.4.9 布局修改,增加保存JSON/脑图为文件,增加JSON过滤,鼠标移入key提示JSONPath
  42. // @note v0.4.8 代码优化
  43. // @note v0.4.7 增加对JSONP的判断,代码优化
  44. // @note v0.4.6 增加复制按钮,JSON脑图CSS样式细节优化,JSON脑图增加收起/展开子节点按钮
  45. // @note v0.4.5 在json-viewer-updated原基础上进行了一些修改,主要有CSS样式修改,新增折叠/展开全部功能,新增JSON脑图功能,脑图节点点击显示调用路径
  46. // ==/UserScript==
  47.  
  48. (o=>{if(!["application/vnd.api+json","application/javascript","application/json","text/javascript","text/plain","text/json"].includes(document.contentType))return;if(typeof GM_addStyle=="function"){GM_addStyle(o);return}const t=document.createElement("style");t.textContent=o,document.head.append(t)})(' @charset "UTF-8";body,html{margin:0;padding:0;font-size:14px}body td,html td{font-size:14px}body li::marker,html li::marker{content:""}body input:focus,body select:focus,body textarea:focus,html input:focus,html select:focus,html textarea:focus{outline:0}.hidden{display:none!important}.layui-layer-tips{width:auto!important}.format-container{z-index:10;position:fixed;width:100vw;height:100vh;display:flex;flex-direction:column}.format-container .tabs,.format-container .toolbar{display:flex;line-height:28px;background-color:#ececec;border-bottom:1px solid #ccc}.format-container .toolbar{line-height:23px}.format-container .toolbar .searchbox{display:flex;flex-grow:1}.format-container .toolbar .searchbox input{flex-grow:1;border:none;outline:none;font-size:12px;padding-left:23px;background-size:12px;background-repeat:no-repeat;background-position:7px center;background-image:url(data:image/svg+xml;base64,PCEtLSBUaGlzIFNvdXJjZSBDb2RlIEZvcm0gaXMgc3ViamVjdCB0byB0aGUgdGVybXMgb2YgdGhlIE1vemlsbGEgUHVibGljCiAgIC0gTGljZW5zZSwgdi4gMi4wLiBJZiBhIGNvcHkgb2YgdGhlIE1QTCB3YXMgbm90IGRpc3RyaWJ1dGVkIHdpdGggdGhpcwogICAtIGZpbGUsIFlvdSBjYW4gb2J0YWluIG9uZSBhdCBodHRwOi8vbW96aWxsYS5vcmcvTVBMLzIuMC8uIC0tPgo8c3ZnIGZpbGw9InJnYmEoMTM1LCAxMzUsIDEzNywgMC45KSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2aWV3Qm94PSIwIDAgMTIgMTIiPgogIDxwYXRoIGZpbGw9ImNvbnRleHQtZmlsbCIgb3BhY2l0eT0iLjQiIGQ9Ik01IDkuMmwyIDEuNlY2LjFMOC41NSA0aC01LjFMNSA2LjF2My4xeiIvPgogIDxwYXRoIGZpbGw9ImNvbnRleHQtZmlsbCIgZD0iTTEuMTggMi42QTEgMSAwIDAgMSAyIDFIMTBhMSAxIDAgMCAxIC44IDEuNkw4IDYuNHY0LjgyYzAgLjYzLS43Mi45OC0xLjIyLjZsLTIuNS0xLjk5QS43NS43NSAwIDAgMSA0IDkuMjVWNi40MUwxLjE4IDIuNnpNMiAyTDUgNi4wOXYzLjA0bDIgMS41OVY2LjA5TDEwLjAxIDJIMnoiLz4KPC9zdmc+Cg==)}.format-container .toolbar .searchbox .clear{flex:0 0 auto;align-self:center;margin:0 4px;padding:0;border:0;width:16px;height:16px;background-color:transparent;background-image:url(data:image/svg+xml;base64,PCEtLSBUaGlzIFNvdXJjZSBDb2RlIEZvcm0gaXMgc3ViamVjdCB0byB0aGUgdGVybXMgb2YgdGhlIE1vemlsbGEgUHVibGljCiAgIC0gTGljZW5zZSwgdi4gMi4wLiBJZiBhIGNvcHkgb2YgdGhlIE1QTCB3YXMgbm90IGRpc3RyaWJ1dGVkIHdpdGggdGhpcwogICAtIGZpbGUsIFlvdSBjYW4gb2J0YWluIG9uZSBhdCBodHRwOi8vbW96aWxsYS5vcmcvTVBMLzIuMC8uIC0tPgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjE2IiBoZWlnaHQ9IjE2IiB2aWV3Qm94PSIwIDAgMTYgMTYiIGZpbGw9ImNvbnRleHQtZmlsbCIgZmlsbC1vcGFjaXR5PSJjb250ZXh0LWZpbGwtb3BhY2l0eSI+CiAgPHBhdGggZD0iTTYuNTg2IDhsLTIuMjkzIDIuMjkzYTEgMSAwIDAgMCAxLjQxNCAxLjQxNEw4IDkuNDE0bDIuMjkzIDIuMjkzYTEgMSAwIDAgMCAxLjQxNC0xLjQxNEw5LjQxNCA4bDIuMjkzLTIuMjkzYTEgMSAwIDEgMC0xLjQxNC0xLjQxNEw4IDYuNTg2IDUuNzA3IDQuMjkzYTEgMSAwIDAgMC0xLjQxNCAxLjQxNEw2LjU4NiA4ek04IDBhOCA4IDAgMSAxIDAgMTZBOCA4IDAgMCAxIDggMHoiLz4KPC9zdmc+Cg==)}.format-container .tabs-item{border-width:3px;border-top:3px solid #ececec}.format-container .tabs-item.active{color:#0060df;border-top-color:#0060df;background-color:#e9e9e9}.format-container .tabs-item:hover{border-top-color:#c3c3c6}.format-container .tabs-item,.format-container .toolbar-item{cursor:pointer;padding:0 10px;font-size:12px}.format-container .tabs-item:hover,.format-container .toolbar-item:hover{background-color:#d4d4d4}.format-container .tabs .selectbox{position:absolute;right:200px;display:flex;font-size:13px}.format-container .inputJson,.format-container .fetchApi{cursor:pointer;color:#0060df;margin-left:15px}.format-container .tabs-container{flex-grow:1;overflow:auto;line-height:1.4;font-family:monospace}.format-container .tabs-container>div{display:none}.format-container .tabs-container>div.active{display:block}.format-container .tabs-container #formatContainer{padding:10px}.format-container .tabs-container #rawTextContainer{padding:0 10px}.format-container .tabs-container #rawTextContainer pre{display:block!important;overflow-wrap:break-word;white-space:pre-wrap}.format-container .jsonp{color:#93983a}.format-container ul.json-object,.format-container ul.json-array{margin:0 0 0 2px;list-style-type:none;border-left:1px dotted #5d6d7e;padding-left:24px}.format-container .json-brackets{font-weight:700}.format-container .json-key{color:#910f93;cursor:pointer}.format-container .json-string,.format-container .json-string a{color:#2e7c16}.format-container .json-number{color:#164ff1}.format-container .json-boolean{color:#905}.format-container .json-null{color:#228fec}.format-container a.json-toggle{position:rElative;color:inherit;opacity:.2;text-decoration:none}.format-container a.json-toggle:hover{opacity:.35}.format-container a.json-toggle:active{opacity:.5}.format-container a.json-toggle:focus{outline:none}.format-container a.json-toggle:before{top:2.5px;left:-15px;position:absolute;content:"";display:block;width:0;height:0;border-style:solid;border-width:5px 0 5px 8px;border-color:transparent transparent transparent currentColor;transform:rotate(90deg)}.format-container a.json-toggle.collapsed:before{transform:rotate(0)}.format-container a.json-placeholder{color:#ccc;font-size:12px;padding:0 1em;text-decoration:none}.format-container a.json-placeholder:hover{text-decoration:underline}.format-container .json-curly-brackets{color:#6d9331}.format-container .json-square-brackets{color:#8e9331}.format-container #jmContainer{width:100vw;height:calc(100vh - 57px)}.format-container #jmContainer jmnode{display:flex;align-items:center;padding:0 7px 0 22px;color:#475872!important;box-shadow:none!important;background-color:transparent!important}.format-container #jmContainer jmnode.root{padding:0;color:transparent!important}.format-container #jmContainer jmnode:before{content:"";top:50%!important;margin-top:1.5px;position:absolute;border-radius:50%;transform:translateY(-50%)}.format-container #jmContainer jmnode.root:before{left:50%;width:18px;height:18px;transform:translate(-18px,-50%)}.format-container #jmContainer jmnode:hover{text-shadow:0px 0px 1px currentColor}.format-container #jmContainer jmnode:not(.root):before{left:0;width:15px;height:15px}.format-container #jmContainer jmexpander{margin-top:1px;line-height:9px;background-color:#dfdfdf}.format-container #jmContainer .datatype{opacity:.6;font-size:12px;margin-top:2px;padding-left:5px}.format-container table{width:-webkit-fill-available;margin-left:20px;border-collapse:collapse}.format-container table tr:hover{background-color:#f0f9fe}.format-container table tr.selected td,.format-container table tr.selected td a{color:#fff!important;background-color:#3875d7}.format-container table tr td:first-child{width:120px}.format-container table .tree-len{color:#ccc;font-size:13px}.format-container table .simple-tree-table-icon{color:#000;opacity:.2;width:0!important;margin:0!important;line-height:0!important}.format-container table .simple-tree-table-icon:before{top:.5px;left:-15px;position:relative;content:"";width:0;height:0;display:none;border-style:solid;border-width:5px 0 5px 8px;border-color:transparent transparent transparent currentColor;transform:rotate(90deg)}.format-container table .simple-tree-table-icon::hover{opacity:.35}.format-container table .simple-tree-table-icon:after{content:""!important}.format-container table .simple-tree-table-icon::active{opacity:.5}.format-container table .simple-tree-table-opened .simple-tree-table-icon:before{display:block}.format-container table .simple-tree-table-closed .simple-tree-table-icon:before{display:block;transform:rotate(0)}.httpRequest{padding:20px}.httpRequest input,.httpRequest select{border-radius:0;padding-left:10px;border:1px solid #ccc}.requestbox,.textarea{width:700px;display:flex}.requestbox{height:35px;margin-bottom:15px}.requestbox input{flex-grow:1}.requestbox button{cursor:pointer;padding:0 15px;border:1px solid #ccc}.requestbox button:active{background-color:#cfcfcf}.textarea input{flex-grow:1;height:30px}.light .json-key{color:#0040cf}.light .json-string,.light .json-string a{color:#a31515}.light .json-number{color:#0b7500}.light .json-boolean{color:#00f}.light .json-null{color:#05f}body.dark li,body.dark pre,body.dark_IntelliJ li,body.dark_IntelliJ pre{color:#ccc}body.dark .jsonp,body.dark_IntelliJ .jsonp{color:#f1d700}body.dark .json-toggle,body.dark_IntelliJ .json-toggle{opacity:.35}body.dark .json-toggle:hover,body.dark_IntelliJ .json-toggle:hover{opacity:.5}body.dark jmnode,body.dark_IntelliJ jmnode{filter:brightness(2)}body.dark table tr:hover,body.dark_IntelliJ table tr:hover{background-color:#353b48}body.dark .simple-tree-table-icon,body.dark_IntelliJ .simple-tree-table-icon{color:#fff;opacity:.5}body.dark .tabs-container{background-color:#333}body.dark .json-curly-brackets{color:#ce70d6}body.dark .json-square-brackets{color:#f1d700}body.dark .json-key{color:#9cdcfe}body.dark .json-string,body.dark .json-string a{color:#ce9178}body.dark .json-number{color:#b5cea8}body.dark .json-boolean{color:#358cd6}body.dark .json-null{color:#569cd6}body.dark_IntelliJ .tabs-container{background-color:#1e1f22}body.dark_IntelliJ .json-curly-brackets{color:#bb9667}body.dark_IntelliJ .json-square-brackets{color:#bbbda3}body.dark_IntelliJ .json-key{color:#c77dbb}body.dark_IntelliJ .json-string,body.dark_IntelliJ .json-string a{color:#499472}body.dark_IntelliJ .json-number{color:#27abb7}body.dark_IntelliJ .json-boolean{color:#ce8d66}body.dark_IntelliJ .json-null{color:#c06235}.scroll-top{width:48px;height:48px;z-index:999;position:fixed;right:30px;bottom:30px;display:none;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAA39JREFUaEPtmV2ITVEUx39rJjT5KPKC5DPKK6UGZZ7Eq0whNUiKFPfcKW9mnmjm7ssLaSLygEx5xItMESnKC4V8FV4IJUkyS+fMHZ07zjl3733PvT6a+3S6Z629/r+99sfa+wgpPw1YDtxLe9/k/1eI4X5STMkSokXWNlloYjgpMZSmIxPgbxBfS8M4QK0eavT78Qw0uodrtd+wDGjAMqBcEVAQw6NaYnzeNwRAi2xBOQlMrYj6jLJTygz6iMzyyR1Ai+xCGUgMqnTmDZErgBYoIJjMXhY2S4mLeWUiNwAt0INwyEqY0iNleq1saxjlAqAB64BrToKEHVLijJNPgnHdALqPaUziOsoKRzGfaKFD+nng6FdlXj+Ay9AZq1Q5L2W2/jEA3c8sWqOSe3aCiK/A3cr/K4G2FKEbxXDZF6KuDKROXKWXFvqlxJdQmBaZzDDdKZP8thhW/RmAgKfA4qrgSq+U6UkSlAostEuJOz4Q3hnQgPXAld+CCh1pB5DogKTcSBAalhpHmw1wGtgxJuhbMczJEqIBbxLmzFUxbGg2gCYE9AVADF6jwctJDzKd73xI7DG/IQQTmCFH+OiaBT+AAyykhWcpBZv7JA4bGmaRHOV5cwBqX7mc5Qe9coyX0TK6n/m0RnVSV4bA1KuTLCi/DBTYhHCpRm+Fe8Bo/b8JmJxp71lqOwNowB7guGuqLe33iuGEpW1k5gTgVDK7qIjbZmyESU1aA1TOuA99dTn5CQulxAsbH3uAeqpOGyXVNrvEcMrGzR4gIGnjsonhYzMkhg4bx3EAm17ysGlIBh4DSzzE+LgMiGG3jaPLEApv2Q7YNFq3jcOmZg9gt/u6aH8PzEx0aGWu9PHapjFrgKimCaIDTHiQqf4pNxHW2AT8ZaMEiZdgSreUKdm25QRQgRi7nIZzI7xZcPmeNkAL5xjmVpVQx1049HUGiCAKFBH6K8GjFUP3MIW2CGJpjd4bFEPnmM54grA761tYWpteAJXgy1A6w6p09Opcu1nED7ZlAcQP/BqwGZjORAblMO9sh03czhsgLZgW6EL4JoYL0b0RTArPBfFnH6G5ZyAVYKTkGBlWQVR2bxDDgvjzvwQQXqGsDQ/sGkTXKdHzOECsB3LtjdjKMjqE/qMMjJwn5olh+98+hM6gvAqXy0aN+4Yuo/HG/weAPmC1GNrzHDbxtn4Coc0pQNdM3UAAAAAASUVORK5CYII=)} ');
  49.  
  50. System.addImportMap({ imports: {"jquery":"user:jquery","jsmind":"user:jsmind","jsmind/screenshot":"user:jsmind/screenshot"} });
  51. System.set("user:jquery", (()=>{const _=jquery;('default' in _)||(_.default=_);return _})());
  52. System.set("user:jsmind", (()=>{const _=jsmind;('default' in _)||(_.default=_);return _})());
  53. System.set("user:jsmind/screenshot", (()=>{const _=jsmind;('default' in _)||(_.default=_);return _})());
  54.  
  55. System.register("./__entry.js", ['./__monkey.entry-Bggv8gqL.js'], (function (exports, module) {
  56. 'use strict';
  57. return {
  58. setters: [null],
  59. execute: (function () {
  60.  
  61.  
  62.  
  63. })
  64. };
  65. }));
  66.  
  67. System.register("./__monkey.entry-Bggv8gqL.js", ['jquery'], (function (exports, module) {
  68. 'use strict';
  69. var $;
  70. return {
  71. setters: [module => {
  72. $ = module.default;
  73. }],
  74. execute: (function () {
  75.  
  76. const scriptRel = function detectScriptRel() {
  77. const relList = typeof document !== "undefined" && document.createElement("link").relList;
  78. return relList && relList.supports && relList.supports("modulepreload") ? "modulepreload" : "preload";
  79. }();
  80. const assetsURL = function(dep) {
  81. return "/" + dep;
  82. };
  83. const seen = {};
  84. const __vitePreload = function preload(baseModule, deps, importerUrl) {
  85. let promise = Promise.resolve();
  86. if (deps && deps.length > 0) {
  87. document.getElementsByTagName("link");
  88. const cspNonceMeta = document.querySelector(
  89. "meta[property=csp-nonce]"
  90. );
  91. const cspNonce = (cspNonceMeta == null ? void 0 : cspNonceMeta.nonce) || (cspNonceMeta == null ? void 0 : cspNonceMeta.getAttribute("nonce"));
  92. promise = Promise.allSettled(
  93. deps.map((dep) => {
  94. dep = assetsURL(dep);
  95. if (dep in seen) return;
  96. seen[dep] = true;
  97. const isCss = dep.endsWith(".css");
  98. const cssSelector = isCss ? '[rel="stylesheet"]' : "";
  99. if (document.querySelector(`link[href="${dep}"]${cssSelector}`)) {
  100. return;
  101. }
  102. const link = document.createElement("link");
  103. link.rel = isCss ? "stylesheet" : scriptRel;
  104. if (!isCss) {
  105. link.as = "script";
  106. }
  107. link.crossOrigin = "";
  108. link.href = dep;
  109. if (cspNonce) {
  110. link.setAttribute("nonce", cspNonce);
  111. }
  112. document.head.appendChild(link);
  113. if (isCss) {
  114. return new Promise((res, rej) => {
  115. link.addEventListener("load", res);
  116. link.addEventListener(
  117. "error",
  118. () => rej(new Error(`Unable to preload CSS for ${dep}`))
  119. );
  120. });
  121. }
  122. })
  123. );
  124. }
  125. function handlePreloadError(err) {
  126. const e = new Event("vite:preloadError", {
  127. cancelable: true
  128. });
  129. e.payload = err;
  130. window.dispatchEvent(e);
  131. if (!e.defaultPrevented) {
  132. throw err;
  133. }
  134. }
  135. return promise.then((res) => {
  136. for (const item of res || []) {
  137. if (item.status !== "rejected") continue;
  138. handlePreloadError(item.reason);
  139. }
  140. return baseModule().catch(handlePreloadError);
  141. });
  142. };
  143. const Utils = exports("U", {
  144. // 检查字符串是否为URL
  145. isUrl: function(string) {
  146. const regexp = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
  147. return regexp.test(string);
  148. },
  149. // 检查是否是图片链接
  150. isImg: function(pathImg) {
  151. const regexp = /\.(ico|bmp|gif|jpg|jpeg|png|svg|webp|GIF|JPG|PNG|WEBP|SVG)([\w#!:.?+=&%@!\-\/])?/i;
  152. return regexp.test(pathImg);
  153. },
  154. // 检验内容是否是json格式的内容
  155. isJSON: function(str) {
  156. try {
  157. JSON.parse(str);
  158. return true;
  159. } catch (e) {
  160. console.log("is not json", e);
  161. return false;
  162. }
  163. },
  164. // 获取数据类型
  165. getType: function(value) {
  166. return Object.prototype.toString.call(value).match(/\s(.+)]/)[1].toLowerCase();
  167. },
  168. // 获取数组中对象key最多的对象
  169. findMaxKeysObject: function(arr) {
  170. let maxKeysCount = 0, maxKeysObject;
  171. for (const obj of arr) {
  172. const keysCount = Object.keys(obj).length;
  173. if (keysCount > maxKeysCount) {
  174. maxKeysCount = keysCount;
  175. maxKeysObject = obj;
  176. }
  177. }
  178. return maxKeysObject;
  179. },
  180. // 随机rgb颜色
  181. randomColor: (opacity) => {
  182. const red = Math.floor(Math.random() * 256);
  183. const green = Math.floor(Math.random() * 256);
  184. const blue = Math.floor(Math.random() * 256);
  185. return `rgba(${red}, ${green}, ${blue}, ${opacity})`;
  186. },
  187. /**
  188. * 是否满足JSON
  189. * @returns
  190. */
  191. isJSONDocument: function(contentType) {
  192. const docType = [
  193. "application/vnd.api+json",
  194. "application/javascript",
  195. "application/json",
  196. "text/javascript",
  197. "text/plain",
  198. "text/json"
  199. ];
  200. if (!docType.includes(contentType)) {
  201. return false;
  202. }
  203. return true;
  204. }
  205. });
  206. var _GM_addStyle = /* @__PURE__ */ (() => typeof GM_addStyle != "undefined" ? GM_addStyle : void 0)();
  207. var _GM_getValue = exports("a", /* @__PURE__ */ (() => typeof GM_getValue != "undefined" ? GM_getValue : void 0)());
  208. var _GM_setClipboard = exports("c", /* @__PURE__ */ (() => typeof GM_setClipboard != "undefined" ? GM_setClipboard : void 0)());
  209. var _GM_setValue = exports("_", /* @__PURE__ */ (() => typeof GM_setValue != "undefined" ? GM_setValue : void 0)());
  210. var _unsafeWindow = exports("b", /* @__PURE__ */ (() => typeof unsafeWindow != "undefined" ? unsafeWindow : void 0)());
  211. (function() {
  212. if (!Utils.isJSONDocument(document.contentType)) {
  213. return;
  214. }
  215. _unsafeWindow.GLOBAL_SOURCE_ELEMENT = $("pre").first();
  216. if (_unsafeWindow.GLOBAL_SOURCE_ELEMENT.length === 0) {
  217. const text = document.body.innerText;
  218. if (!Utils.isJSON(text)) {
  219. return;
  220. }
  221. const pre = document.createElement("pre");
  222. pre.innerText = text;
  223. document.body.insertAdjacentHTML("afterbegin", pre);
  224. _unsafeWindow.GLOBAL_SOURCE_ELEMENT = $(pre);
  225. }
  226. let rawText = _unsafeWindow.GLOBAL_SOURCE_ELEMENT.text();
  227. if (!rawText) {
  228. return;
  229. }
  230. let tokens = rawText.match(/^([^\s(]*)\s*\(([\s\S]*)\)\s*;?$/);
  231. if (tokens && tokens[1] && tokens[2]) {
  232. _unsafeWindow.GLOBAL_JSONP_FUN = tokens[1];
  233. rawText = tokens[2];
  234. }
  235. if (!Utils.isJSON(rawText)) {
  236. return;
  237. }
  238. _unsafeWindow.GLOBAL_SOURCE_ELEMENT.hide();
  239. try {
  240. _unsafeWindow.GLOBAL_JSON = eval(`(${rawText})`);
  241. } catch (e) {
  242. _unsafeWindow.GLOBAL_JSON = JSON.parse(rawText);
  243. }
  244. const layuiJs = "//unpkg.com/layui@2.7.6/dist/layui.js";
  245. const layuiCss = "//unpkg.com/layui@2.7.6/dist/css/layui.css";
  246. $("head").append(`<link href="${layuiCss}" rel="stylesheet">`).append(`<script src="${layuiJs}">`);
  247. _GM_addStyle(`
  248. jmnode.root::before{
  249. background-color: ${Utils.randomColor(0.5)}
  250. }
  251.  
  252. jmnode:not(.root)::before{
  253. background-color: ${Utils.randomColor(0.5)}
  254. }
  255. `);
  256. __vitePreload(() => module.import('./index-YA0dljc1-C2SpHS29.js'), void 0 );
  257. __vitePreload(() => module.import('./index-LZKktZtm-Dp6comsF.js'), void 0 ).then((format) => format.default.init()).then(() => __vitePreload(() => module.import('./index-DwqDuu_A-B9CcxBqC.js'), void 0 )).then(() => __vitePreload(() => module.import('./index-Cgl7hcfy-DaTAQqy4.js'), void 0 ));
  258. })();
  259.  
  260. })
  261. };
  262. }));
  263.  
  264. System.register("./index-YA0dljc1-C2SpHS29.js", [], (function (exports, module) {
  265. 'use strict';
  266. return {
  267. execute: (function () {
  268.  
  269. const layout = `
  270. <div class="format-container">
  271. <div>
  272. <div class="tabs">
  273. <div class="tabs-item btn active" id="format">JSON格式化</div>
  274. <div class="tabs-item btn" id="viewJsonMind">JSON脑图</div>
  275. <div class="tabs-item btn" id="viewRawText">原始数据</div>
  276. <div class="selectbox">
  277. <div class="formatStyle">
  278. <label>风格:</label>
  279. <select>
  280. <option value="default">默认</option>
  281. <option value="treaTable">表格</option>
  282. </select>
  283. </div>
  284. <div class="theme" style="margin: 0 15px">
  285. <label>主题: </label>
  286. <select>
  287. <option value="default">默认</option>
  288. <option value="light">浅色</option>
  289. <option value="dark">暗黑</option>
  290. <option value="dark_IntelliJ">暗黑+</option>
  291. </select>
  292. </div>
  293. <span class="inputJson">JSON 输入</span>
  294. <span class="fetchApi">HTTP 请求</span>
  295. </div>
  296. </div>
  297. <div class="toolbar">
  298. <div class="toolbar-item btn" id="saveJson">保存</div>
  299. <div class="toolbar-item btn" id="copyJson">复制</div>
  300. <div class="toolbar-item btn" id="collapseAll">全部折叠</div>
  301. <div class="toolbar-item btn" id="expandAll">全部展开</div>
  302. <div class="toolbar-item btn" id="jsoncrack" style="display: none;">JSON Crack</div>
  303. <div class="toolbar-item btn" id="beautify" style="display: none;">美化输出</div>
  304. <div class="searchbox">
  305. <input type="text" placeholder="过滤 JSON "/>
  306. <button class="clear" hidden></button>
  307. </div>
  308. </div>
  309. </div>
  310. <div class="tabs-container">
  311. <div class="active" id="formatContainer"></div>
  312. <div id="jmContainer"></div>
  313. <div id="rawTextContainer"><pre></pre></div>
  314. </div>
  315. </div>`;
  316. document.body.insertAdjacentHTML("afterbegin", layout);
  317.  
  318. })
  319. };
  320. }));
  321.  
  322. System.register("./index-LZKktZtm-Dp6comsF.js", ['jquery', './__monkey.entry-Bggv8gqL.js'], (function (exports, module) {
  323. 'use strict';
  324. var $, _GM_setValue, _GM_getValue, _unsafeWindow, Utils, _GM_setClipboard;
  325. return {
  326. setters: [module => {
  327. $ = module.default;
  328. }, module => {
  329. _GM_setValue = module._;
  330. _GM_getValue = module.a;
  331. _unsafeWindow = module.b;
  332. Utils = module.U;
  333. _GM_setClipboard = module.c;
  334. }],
  335. execute: (function () {
  336.  
  337. (function($2) {
  338. function isCollapsable(arg) {
  339. return arg instanceof Object && Object.keys(arg).length > 0;
  340. }
  341. function json2html(json, parentPath = "") {
  342. let html = "", type = Utils.getType(json);
  343. switch (type) {
  344. case "array":
  345. case "object":
  346. let len = json.length || Object.keys(json).length;
  347. if (len > 0) {
  348. html += `<span class="json-brackets ${type == "array" ? "json-square-brackets" : "json-curly-brackets"}">`;
  349. html += type === "array" ? '[</span><ol class="json-array">' : '{</span><ul class="json-object">';
  350. for (var key in json) {
  351. if (json.hasOwnProperty(key)) {
  352. let comma = --len > 0 ? "," : "", jsonPath = parentPath + "." + key, collapse = isCollapsable(json[key]) ? '<a href class="json-toggle"></a>' : "", res = json2html(json[key], jsonPath);
  353. let toHtml = type === "array" ? res : `<span class="json-key">"${key}"</span>: ${res}`;
  354. html += [
  355. `<li json-path="${jsonPath}">`,
  356. collapse,
  357. toHtml,
  358. comma,
  359. "</li>"
  360. ].join("");
  361. }
  362. }
  363. if (type === "array") {
  364. html += `</ol><span class="json-brackets json-square-brackets">]</span>`;
  365. } else {
  366. html += `</ul><span class="json-brackets json-curly-brackets">}</span>`;
  367. }
  368. } else {
  369. html += `<span class="json-brackets ${type == "array" ? "json-square-brackets" : "json-curly-brackets"}">`;
  370. html += type === "array" ? "[]" : "{}";
  371. html += "</span>";
  372. }
  373. break;
  374. default:
  375. json = type === "string" ? json.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;") : json;
  376. if (Utils.isUrl(json)) {
  377. html += `<a target="_blank" href="${json}" class="json-string">"${json}"</a>`;
  378. } else {
  379. json = type === "string" ? `"${json}"` : json;
  380. html += `<span class="json-${type}">${json}</span>`;
  381. }
  382. break;
  383. }
  384. return html;
  385. }
  386. $2.fn.jsonViewer = function(json, jsonpFn) {
  387. return this.each(function() {
  388. var html = json2html(json);
  389. if (jsonpFn !== void 0 && jsonpFn !== null) {
  390. html = `<div class="jsonp">${jsonpFn}(</div>${html}<div class="jsonp">)</div>`;
  391. }
  392. $2(this).html(html);
  393. $2(this).off("click");
  394. $2(this).on("click", "a.json-toggle", function() {
  395. var target = $2(this).toggleClass("collapsed").siblings("ul.json-object, ol.json-array");
  396. target.toggle();
  397. if (target.is(":visible")) {
  398. target.siblings(".json-placeholder").remove();
  399. } else {
  400. var count = target.children('li:not([class*="hidden"])').length;
  401. var placeholder = count + (count > 1 ? " items" : " item");
  402. target.after(
  403. '<a href class="json-placeholder">' + placeholder + "</a>"
  404. );
  405. }
  406. return false;
  407. });
  408. $2(this).on("click", "a.json-placeholder", function() {
  409. $2(this).siblings("a.json-toggle").click();
  410. $2(this).siblings("a.json-placeholder").remove();
  411. return false;
  412. });
  413. });
  414. };
  415. })($);
  416. !function(e) {
  417. var t = {};
  418. function n(o) {
  419. if (t[o]) return t[o].exports;
  420. var i = t[o] = { i: o, l: false, exports: {} };
  421. return e[o].call(i.exports, i, i.exports, n), i.l = true, i.exports;
  422. }
  423. n.m = e, n.c = t, n.d = function(e2, t2, o) {
  424. n.o(e2, t2) || Object.defineProperty(e2, t2, { enumerable: true, get: o });
  425. }, n.r = function(e2) {
  426. "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e2, "__esModule", { value: true });
  427. }, n.t = function(e2, t2) {
  428. if (1 & t2 && (e2 = n(e2)), 8 & t2) return e2;
  429. if (4 & t2 && "object" == typeof e2 && e2 && e2.__esModule) return e2;
  430. var o = /* @__PURE__ */ Object.create(null);
  431. if (n.r(o), Object.defineProperty(o, "default", { enumerable: true, value: e2 }), 2 & t2 && "string" != typeof e2) for (var i in e2) n.d(o, i, (function(t3) {
  432. return e2[t3];
  433. }).bind(null, i));
  434. return o;
  435. }, n.n = function(e2) {
  436. var t2 = e2 && e2.__esModule ? function() {
  437. return e2.default;
  438. } : function() {
  439. return e2;
  440. };
  441. return n.d(t2, "a", t2), t2;
  442. }, n.o = function(e2, t2) {
  443. return Object.prototype.hasOwnProperty.call(e2, t2);
  444. }, n.p = "/dist", n(n.s = 5);
  445. }([function(e, t) {
  446. e.exports = $;
  447. }, function(e, t, n) {
  448. var o = n(2), i = n(3);
  449. "string" == typeof (i = i.__esModule ? i.default : i) && (i = [[e.i, i, ""]]);
  450. var a = { insert: "head", singleton: false };
  451. o(i, a);
  452. e.exports = i.locals || {};
  453. }, function(e, t, n) {
  454. var o, i = function() {
  455. return void 0 === o && (o = Boolean(window && document && document.all && !window.atob)), o;
  456. }, a = /* @__PURE__ */ function() {
  457. var e2 = {};
  458. return function(t2) {
  459. if (void 0 === e2[t2]) {
  460. var n2 = document.querySelector(t2);
  461. if (window.HTMLIFrameElement && n2 instanceof window.HTMLIFrameElement) try {
  462. n2 = n2.contentDocument.head;
  463. } catch (e3) {
  464. n2 = null;
  465. }
  466. e2[t2] = n2;
  467. }
  468. return e2[t2];
  469. };
  470. }(), r = [];
  471. function s(e2) {
  472. for (var t2 = -1, n2 = 0; n2 < r.length; n2++) if (r[n2].identifier === e2) {
  473. t2 = n2;
  474. break;
  475. }
  476. return t2;
  477. }
  478. function c(e2, t2) {
  479. for (var n2 = {}, o2 = [], i2 = 0; i2 < e2.length; i2++) {
  480. var a2 = e2[i2], c2 = t2.base ? a2[0] + t2.base : a2[0], l2 = n2[c2] || 0, u2 = "".concat(c2, " ").concat(l2);
  481. n2[c2] = l2 + 1;
  482. var d2 = s(u2), f2 = { css: a2[1], media: a2[2], sourceMap: a2[3] };
  483. -1 !== d2 ? (r[d2].references++, r[d2].updater(f2)) : r.push({ identifier: u2, updater: y(f2, t2), references: 1 }), o2.push(u2);
  484. }
  485. return o2;
  486. }
  487. function l(e2) {
  488. var t2 = document.createElement("style"), o2 = e2.attributes || {};
  489. if (void 0 === o2.nonce) {
  490. var i2 = n.nc;
  491. i2 && (o2.nonce = i2);
  492. }
  493. if (Object.keys(o2).forEach(function(e3) {
  494. t2.setAttribute(e3, o2[e3]);
  495. }), "function" == typeof e2.insert) e2.insert(t2);
  496. else {
  497. var r2 = a(e2.insert || "head");
  498. if (!r2) throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");
  499. r2.appendChild(t2);
  500. }
  501. return t2;
  502. }
  503. var u, d = (u = [], function(e2, t2) {
  504. return u[e2] = t2, u.filter(Boolean).join("\n");
  505. });
  506. function f(e2, t2, n2, o2) {
  507. var i2 = n2 ? "" : o2.media ? "@media ".concat(o2.media, " {").concat(o2.css, "}") : o2.css;
  508. if (e2.styleSheet) e2.styleSheet.cssText = d(t2, i2);
  509. else {
  510. var a2 = document.createTextNode(i2), r2 = e2.childNodes;
  511. r2[t2] && e2.removeChild(r2[t2]), r2.length ? e2.insertBefore(a2, r2[t2]) : e2.appendChild(a2);
  512. }
  513. }
  514. function h(e2, t2, n2) {
  515. var o2 = n2.css, i2 = n2.media, a2 = n2.sourceMap;
  516. if (i2 ? e2.setAttribute("media", i2) : e2.removeAttribute("media"), a2 && btoa && (o2 += "\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(a2)))), " */")), e2.styleSheet) e2.styleSheet.cssText = o2;
  517. else {
  518. for (; e2.firstChild; ) e2.removeChild(e2.firstChild);
  519. e2.appendChild(document.createTextNode(o2));
  520. }
  521. }
  522. var p = null, v = 0;
  523. function y(e2, t2) {
  524. var n2, o2, i2;
  525. if (t2.singleton) {
  526. var a2 = v++;
  527. n2 = p || (p = l(t2)), o2 = f.bind(null, n2, a2, false), i2 = f.bind(null, n2, a2, true);
  528. } else n2 = l(t2), o2 = h.bind(null, n2, t2), i2 = function() {
  529. !function(e3) {
  530. if (null === e3.parentNode) return false;
  531. e3.parentNode.removeChild(e3);
  532. }(n2);
  533. };
  534. return o2(e2), function(t3) {
  535. if (t3) {
  536. if (t3.css === e2.css && t3.media === e2.media && t3.sourceMap === e2.sourceMap) return;
  537. o2(e2 = t3);
  538. } else i2();
  539. };
  540. }
  541. e.exports = function(e2, t2) {
  542. (t2 = t2 || {}).singleton || "boolean" == typeof t2.singleton || (t2.singleton = i());
  543. var n2 = c(e2 = e2 || [], t2);
  544. return function(e3) {
  545. if (e3 = e3 || [], "[object Array]" === Object.prototype.toString.call(e3)) {
  546. for (var o2 = 0; o2 < n2.length; o2++) {
  547. var i2 = s(n2[o2]);
  548. r[i2].references--;
  549. }
  550. for (var a2 = c(e3, t2), l2 = 0; l2 < n2.length; l2++) {
  551. var u2 = s(n2[l2]);
  552. 0 === r[u2].references && (r[u2].updater(), r.splice(u2, 1));
  553. }
  554. n2 = a2;
  555. }
  556. };
  557. };
  558. }, function(e, t, n) {
  559. (t = n(4)(false)).push([e.i, ".simple-tree-table-icon{display:inline-block;width:1.5em;line-height:1.5em;margin:0.1em;background-color:#eee;text-align:center;cursor:pointer}.simple-tree-table-opened .simple-tree-table-icon:after{content:'-'}.simple-tree-table-closed .simple-tree-table-icon:after{content:'+'}\n", ""]), e.exports = t;
  560. }, function(e, t, n) {
  561. e.exports = function(e2) {
  562. var t2 = [];
  563. return t2.toString = function() {
  564. return this.map(function(t3) {
  565. var n2 = function(e3, t4) {
  566. var n3 = e3[1] || "", o = e3[3];
  567. if (!o) return n3;
  568. if (t4 && "function" == typeof btoa) {
  569. var i = (r = o, s = btoa(unescape(encodeURIComponent(JSON.stringify(r)))), c = "sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(s), "/*# ".concat(c, " */")), a = o.sources.map(function(e4) {
  570. return "/*# sourceURL=".concat(o.sourceRoot || "").concat(e4, " */");
  571. });
  572. return [n3].concat(a).concat([i]).join("\n");
  573. }
  574. var r, s, c;
  575. return [n3].join("\n");
  576. }(t3, e2);
  577. return t3[2] ? "@media ".concat(t3[2], " {").concat(n2, "}") : n2;
  578. }).join("");
  579. }, t2.i = function(e3, n2, o) {
  580. "string" == typeof e3 && (e3 = [[null, e3, ""]]);
  581. var i = {};
  582. if (o) for (var a = 0; a < this.length; a++) {
  583. var r = this[a][0];
  584. null != r && (i[r] = true);
  585. }
  586. for (var s = 0; s < e3.length; s++) {
  587. var c = [].concat(e3[s]);
  588. o && i[c[0]] || (n2 && (c[2] ? c[2] = "".concat(n2, " and ").concat(c[2]) : c[2] = n2), t2.push(c));
  589. }
  590. }, t2;
  591. };
  592. }, function(e, t, n) {
  593. n.r(t);
  594. var o = n(0), i = n.n(o);
  595. function a(e2, t2) {
  596. if (!(e2 instanceof t2)) throw new TypeError("Cannot call a class as a function");
  597. }
  598. function r(e2, t2) {
  599. for (var n2 = 0; n2 < t2.length; n2++) {
  600. var o2 = t2[n2];
  601. o2.enumerable = o2.enumerable || false, o2.configurable = true, "value" in o2 && (o2.writable = true), Object.defineProperty(e2, o2.key, o2);
  602. }
  603. }
  604. function s(e2, t2, n2) {
  605. return t2 && r(e2.prototype, t2), e2;
  606. }
  607. var c = function() {
  608. function e2() {
  609. var t2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
  610. a(this, e2), this.opts = { type: t2.type || "session", key: t2.key }, this.inst = new l(this.opts);
  611. }
  612. return s(e2, [{ key: "get", value: function() {
  613. var e3 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : null;
  614. return this.inst.get(this.opts.key) || e3;
  615. } }, { key: "set", value: function(e3) {
  616. this.inst.set(this.opts.key, e3);
  617. } }, { key: "remove", value: function() {
  618. this.inst.remove(this.opts.key);
  619. } }]), e2;
  620. }(), l = function() {
  621. function e2() {
  622. var t2 = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
  623. a(this, e2), this.storage = { local: window.localStorage, session: window.sessionStorage }[t2.type];
  624. }
  625. return s(e2, [{ key: "get", value: function(e3) {
  626. try {
  627. var t2 = this.storage.getItem(e3);
  628. return t2 ? JSON.parse(t2) : null;
  629. } catch (e4) {
  630. return console.log(e4), null;
  631. }
  632. } }, { key: "set", value: function(e3, t2) {
  633. try {
  634. this.storage.setItem(e3, JSON.stringify(t2));
  635. } catch (e4) {
  636. console.log(e4);
  637. }
  638. } }, { key: "remove", value: function(e3) {
  639. this.storage.removeItem(e3);
  640. } }]), e2;
  641. }(), u = (n(1), "simple-tree-table");
  642. function d(e2, t2) {
  643. if (!(e2 instanceof t2)) throw new TypeError("Cannot call a class as a function");
  644. }
  645. function f(e2, t2) {
  646. for (var n2 = 0; n2 < t2.length; n2++) {
  647. var o2 = t2[n2];
  648. o2.enumerable = o2.enumerable || false, o2.configurable = true, "value" in o2 && (o2.writable = true), Object.defineProperty(e2, o2.key, o2);
  649. }
  650. }
  651. var h = { expander: null, collapser: null, opened: "all", margin: 20, iconPosition: "> :first-child", iconTemplate: "<span />", store: null, storeKey: null }, p = function() {
  652. function e2(t3) {
  653. var n3 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {};
  654. d(this, e2), this.options = i.a.extend({}, h, n3), this.$table = i()(t3), this.$expander = i()(this.options.expander), this.$collapser = i()(this.options.collapser), this.options.store && this.options.storeKey && (this.store = new c({ type: this.options.store, key: this.options.storeKey })), this.init(), this.load();
  655. }
  656. var t2, n2, o2;
  657. return t2 = e2, o2 = [{ key: "getDefaults", value: function() {
  658. return h;
  659. } }, { key: "setDefaults", value: function(e3) {
  660. return i.a.extend(h, e3);
  661. } }], (n2 = [{ key: "init", value: function() {
  662. this.$table.addClass(u), this.build(), this.unbind(), this.bind();
  663. } }, { key: "destroy", value: function() {
  664. var e3 = function(e4, t3) {
  665. var n3 = new RegExp("".concat(u, "(-\\S+)?"), "g");
  666. return (t3.match(n3) || []).join(" ");
  667. };
  668. this.$table.removeClass(e3), this.nodes().removeClass(e3), this.$table.find(".".concat(u, "-icon")).remove(), this.unbind();
  669. } }, { key: "build", value: function() {
  670. var e3 = this;
  671. this.nodes().not("[data-node-depth]").each(function(t3, n3) {
  672. var o3 = i()(n3), a2 = e3.depth(o3);
  673. o3.data("node-depth", a2), 1 == a2 && o3.addClass("".concat(u, "-root"));
  674. }), this.nodes().filter(function(t3, n3) {
  675. return 0 == i()(n3).find(e3.options.iconPosition).find(".".concat(u, "-handler")).length;
  676. }).each(function(t3, n3) {
  677. var o3 = i()(n3), a2 = e3.depth(o3), r2 = e3.options.margin * (a2 - 1), s2 = i()(e3.options.iconTemplate).addClass("".concat(u, "-handler ").concat(u, "-icon")).css("margin-left", "".concat(r2, "px"));
  678. o3.find(e3.options.iconPosition).prepend(s2);
  679. }), this.nodes().not(".".concat(u, "-empty, .").concat(u, "-opened, .").concat(u, "-closed")).each(function(t3, n3) {
  680. var o3 = i()(n3);
  681. e3.hasChildren(o3) ? e3.opensDefault(o3) ? o3.addClass("".concat(u, "-opened")) : o3.addClass("".concat(u, "-closed")) : o3.addClass("".concat(u, "-empty"));
  682. }), this.nodes().filter(".".concat(u, "-opened")).each(function(t3, n3) {
  683. e3.show(i()(n3));
  684. }), this.nodes().filter(".".concat(u, "-closed")).each(function(t3, n3) {
  685. e3.hide(i()(n3));
  686. });
  687. } }, { key: "opensDefault", value: function(e3) {
  688. var t3 = this.options.opened;
  689. return t3 && ("all" == t3 || -1 != t3.indexOf(e3.data("node-id")));
  690. } }, { key: "bind", value: function() {
  691. var e3 = this;
  692. this.$expander.on("click.".concat(u), function(t3) {
  693. e3.expand();
  694. }), this.$collapser.on("click.".concat(u), function(t3) {
  695. e3.collapse();
  696. }), this.$table.on("click.".concat(u), "tr .".concat(u, "-handler"), function(t3) {
  697. var n3 = i()(t3.currentTarget).closest("tr");
  698. n3.hasClass("".concat(u, "-opened")) ? e3.close(n3) : e3.open(n3);
  699. });
  700. } }, { key: "unbind", value: function() {
  701. this.$expander.off(".".concat(u)), this.$collapser.off(".".concat(u)), this.$table.off(".".concat(u, " node:open node:close"));
  702. } }, { key: "expand", value: function() {
  703. var e3 = this;
  704. this.nodes().each(function(t3, n3) {
  705. e3.show(i()(n3));
  706. }), this.save();
  707. } }, { key: "collapse", value: function() {
  708. var e3 = this;
  709. this.nodes().each(function(t3, n3) {
  710. e3.hide(i()(n3));
  711. }), this.save();
  712. } }, { key: "nodes", value: function() {
  713. return this.$table.find("tr[data-node-id]");
  714. } }, { key: "depth", value: function(e3) {
  715. var t3 = e3.data("node-depth");
  716. if (t3) return t3;
  717. var n3 = this.findByID(e3.data("node-pid"));
  718. return 0 != n3.length ? this.depth(n3) + 1 : 1;
  719. } }, { key: "open", value: function(e3) {
  720. this.show(e3), this.save(), e3.trigger("node:open", [e3]);
  721. } }, { key: "show", value: function(e3) {
  722. e3.hasClass("".concat(u, "-empty")) || (e3.removeClass("".concat(u, "-closed")).addClass("".concat(u, "-opened")), this.showDescs(e3));
  723. } }, { key: "showDescs", value: function(e3) {
  724. var t3 = this;
  725. this.findChildren(e3).each(function(e4, n3) {
  726. var o3 = i()(n3);
  727. o3.show(), o3.hasClass("".concat(u, "-opened")) && t3.showDescs(o3);
  728. });
  729. } }, { key: "close", value: function(e3) {
  730. this.hide(e3), this.save(), e3.trigger("node:close", [e3]);
  731. } }, { key: "hide", value: function(e3) {
  732. e3.hasClass("".concat(u, "-empty")) || (e3.removeClass("".concat(u, "-opened")).addClass("".concat(u, "-closed")), this.hideDescs(e3));
  733. } }, { key: "hideDescs", value: function(e3) {
  734. var t3 = this;
  735. this.findChildren(e3).each(function(e4, n3) {
  736. var o3 = i()(n3);
  737. o3.hide(), t3.hideDescs(o3);
  738. });
  739. } }, { key: "hasChildren", value: function(e3) {
  740. return 0 != this.findChildren(e3).length;
  741. } }, { key: "findChildren", value: function(e3) {
  742. var t3 = e3.data("node-id");
  743. return this.$table.find('tr[data-node-pid="'.concat(t3, '"]'));
  744. } }, { key: "findDescendants", value: function(e3) {
  745. var t3 = this, n3 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : [], o3 = this.findChildren(e3);
  746. return n3.push(o3), o3.each(function(e4, o4) {
  747. t3.findDescendants(i()(o4), n3);
  748. }), n3;
  749. } }, { key: "findByID", value: function(e3) {
  750. return this.$table.find('tr[data-node-id="'.concat(e3, '"]'));
  751. } }, { key: "openByID", value: function(e3) {
  752. this.open(this.findByID(e3));
  753. } }, { key: "closeByID", value: function(e3) {
  754. this.close(this.findByID(e3));
  755. } }, { key: "load", value: function() {
  756. var e3 = this;
  757. if (this.store) {
  758. var t3 = this.store.get();
  759. t3 && (this.nodes().each(function(t4, n3) {
  760. e3.show(i()(n3));
  761. }), this.nodes().filter(function(e4, n3) {
  762. return -1 != t3.indexOf(i()(n3).data("node-id"));
  763. }).each(function(t4, n3) {
  764. e3.hide(i()(n3));
  765. }));
  766. }
  767. } }, { key: "save", value: function() {
  768. if (this.store) {
  769. var e3 = this.nodes().filter(".".concat(u, "-closed")).map(function(e4, t3) {
  770. return i()(t3).data("node-id");
  771. }).get();
  772. this.store.set(e3);
  773. }
  774. } }]) && f(t2.prototype, n2), o2 && f(t2, o2), e2;
  775. }();
  776. i.a.fn.simpleTreeTable = function(e2) {
  777. return this.each(function(t2, n2) {
  778. var o2 = i()(n2);
  779. o2.data(u) && o2.data(u).destroy(), o2.data(u, new p(o2, e2));
  780. });
  781. }, i.a.SimpleTreeTable = p;
  782. }]);
  783. function treeTableTrHTML(json, level = 0, pId = "", pChain = "") {
  784. let tr = "";
  785. for (const key in json) {
  786. let val = json[key], type = Utils.getType(val), tId = key + "_" + Math.random(), chain = pChain + "." + key;
  787. if (["array", "object"].includes(type)) {
  788. let brackets = "", len = Object.keys(val).length, res = treeTableTrHTML(val, level + 1, tId, chain);
  789. if (!res) {
  790. if (type === "array") {
  791. brackets = `<span class="json-brackets json-square-brackets">[]</span>`;
  792. } else {
  793. brackets = `<span class="json-brackets json-curly-brackets">{}</span>`;
  794. }
  795. }
  796. tr += `
  797. <tr data-node-id="${tId}" data-node-pid="${pId}" type="${type}">
  798. <td class="json-key" json-path="${chain}" style="padding-left: ${level * 19}px">${key}:
  799. <span class="tree-len">${len > 0 ? type === "array" ? "[" + len + "]" : "{" + len + "}" : ""}</span>
  800. </td>
  801. <td>${brackets}</td>
  802. </tr>`;
  803. tr += res;
  804. } else {
  805. val = type === "string" ? val.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;") : val;
  806. tr += `<tr data-node-id="${tId}" data-node-pid="${pId}" type="${type}">
  807. <td class="json-key" json-path="${chain}" style="padding-left: ${level * 19}px">${key}:</td>`;
  808. if (Utils.isUrl(val)) {
  809. tr += `<td class="json-${type}"><a target="_blank" href="${val}">"${val}"</a></td>`;
  810. } else {
  811. val = type === "string" ? `"${val}"` : val;
  812. tr += `<td class="json-${type}">${val}</td>`;
  813. }
  814. tr += "</tr>";
  815. }
  816. }
  817. return tr;
  818. }
  819. const evnet = {
  820. /**
  821. * a标签鼠标移入,看是否是图片,是图片生成预览图
  822. * @returns this
  823. */
  824. urlHover: function() {
  825. $("#formatContainer").on(
  826. {
  827. mouseenter: function() {
  828. var that = $(this), href = that.attr("href");
  829. if (Utils.isImg(href)) {
  830. layer.tips(`<img src="${href}" />`, that, {
  831. time: 0,
  832. anim: 5,
  833. maxWidth: 500,
  834. tips: [3, "#d9d9d9"]
  835. });
  836. }
  837. },
  838. mouseleave: () => layer.closeAll()
  839. },
  840. "a[href]"
  841. );
  842. return this;
  843. },
  844. /**
  845. * 鼠标移入key提示JSONPath
  846. * @returns this
  847. */
  848. tipsJsonPath: function() {
  849. var that = this;
  850. $("#formatContainer").on(
  851. {
  852. mouseenter: function() {
  853. const jsonPath = that.getJsonPath(this);
  854. const tips = `<b>ctrl + 点击复制</b><br/>${jsonPath}`;
  855. layer.tips(tips, this, {
  856. time: 0,
  857. anim: 5,
  858. maxWidth: 500,
  859. tips: [1, "#2e59a7"]
  860. });
  861. },
  862. mouseleave: () => layer.closeAll()
  863. },
  864. ".json-key"
  865. );
  866. return this;
  867. },
  868. /**
  869. * 复制key的JSONPath
  870. * @returns
  871. */
  872. copyJsonPath: function() {
  873. var that = this;
  874. $("#formatContainer").on("click", ".json-key", function(event) {
  875. if (event.ctrlKey) {
  876. const jsonPath = that.getJsonPath(this);
  877. _GM_setClipboard(jsonPath);
  878. layer.msg("复制成功", { time: 1500 });
  879. }
  880. });
  881. return this;
  882. },
  883. /**
  884. * 给定htmlElement获取JSONPath
  885. * @param {*} element
  886. * @returns
  887. */
  888. getJsonPath: function(element) {
  889. const style = _GM_getValue("formatStyle") || "default";
  890. const jsonPath = style == "default" ? $(element).parent().attr("json-path") : $(element).attr("json-path");
  891. return jsonPath.split(".").reduce(
  892. (prev, next) => /^\d+$/.test(next) ? prev + `[${next}]` : prev + "." + next
  893. );
  894. },
  895. init: function() {
  896. this.urlHover().tipsJsonPath().copyJsonPath();
  897. }
  898. };
  899. const formatStyle = exports("default", {
  900. // 切换风格
  901. changeStyle: function() {
  902. const that = this;
  903. $(".formatStyle select").on("change", function(e) {
  904. layer.load(0, { shade: false });
  905. const val = $(e.target).val();
  906. _GM_setValue("formatStyle", val);
  907. that.setStyle();
  908. layer.closeAll();
  909. });
  910. return this;
  911. },
  912. // 设置风格
  913. setStyle: function() {
  914. const style = _GM_getValue("formatStyle") || "default";
  915. $(".formatStyle select").val(style);
  916. $("input").val("");
  917. $("#formatContainer").html("");
  918. if (style === "default") {
  919. $("#formatContainer").jsonViewer(
  920. _unsafeWindow.GLOBAL_JSON,
  921. _unsafeWindow.GLOBAL_JSONP_FUN
  922. );
  923. } else {
  924. const trHTML = treeTableTrHTML(_unsafeWindow.GLOBAL_JSON);
  925. let appendHtml = `<table id="treeTable">${trHTML}</table>`;
  926. if (_unsafeWindow.GLOBAL_JSONP_FUN !== void 0 && _unsafeWindow.GLOBAL_JSONP_FUN !== null) {
  927. appendHtml = `<div class="jsonp">${_unsafeWindow.GLOBAL_JSONP_FUN}(</div>${appendHtml}<div class="jsonp">)</div>`;
  928. }
  929. $("#formatContainer").append(appendHtml);
  930. $("#treeTable").simpleTreeTable({
  931. expander: "#expandAll",
  932. collapser: "#collapseAll"
  933. });
  934. $("#treeTable").on("mousedown", "tr", function() {
  935. $(".selected").not(this).removeClass("selected");
  936. $(this).toggleClass("selected");
  937. });
  938. }
  939. return this;
  940. },
  941. init: function() {
  942. this.setStyle().changeStyle();
  943. evnet.init();
  944. }
  945. });
  946. window.addEventListener("message", function(event) {
  947. const { data } = event;
  948. if (data && data.reload) {
  949. formatStyle.setStyle();
  950. }
  951. });
  952.  
  953. })
  954. };
  955. }));
  956.  
  957. System.register("./index-DwqDuu_A-B9CcxBqC.js", ['jquery', './__monkey.entry-Bggv8gqL.js', 'jsmind', 'jsmind/screenshot'], (function (exports, module) {
  958. 'use strict';
  959. var $, _unsafeWindow, _GM_setClipboard, Utils, _GM_getValue, _GM_setValue, jsMind;
  960. return {
  961. setters: [module => {
  962. $ = module.default;
  963. }, module => {
  964. _unsafeWindow = module.b;
  965. _GM_setClipboard = module.c;
  966. Utils = module.U;
  967. _GM_getValue = module.a;
  968. _GM_setValue = module._;
  969. }, module => {
  970. jsMind = module.default;
  971. }, null],
  972. execute: (function () {
  973.  
  974. const cssLoader = (e) => {
  975. const t = GM_getResourceText(e);
  976. return GM_addStyle(t), t;
  977. };
  978. cssLoader("jsmind");
  979. const jsonMind = {
  980. isFirst: true,
  981. // JSON数据转换为jsMind所需要的数据结构
  982. convert: function(json2) {
  983. const children = [];
  984. if (typeof json2 === "object") {
  985. for (const key in json2) {
  986. let val = json2[key], isArray = Array.isArray(val);
  987. if (isArray && val.length > 0) {
  988. val = Utils.findMaxKeysObject(val);
  989. }
  990. const type = Object.prototype.toString.call(val).match(/\s(.+)]/)[1];
  991. children.push({
  992. isArray,
  993. chain: key,
  994. id: key + "_" + Math.random(),
  995. topic: `${key}<span class="datatype">${type}</span>`,
  996. children: this.convert(val)
  997. });
  998. }
  999. }
  1000. return children;
  1001. },
  1002. // 脑图节点调用链
  1003. mindChain: function(node) {
  1004. let chain = node.data.chain;
  1005. if (!node.parent) {
  1006. return chain;
  1007. }
  1008. const parent = node.parent, parentChain = this.mindChain(parent);
  1009. chain = parent.data.isArray ? `${parentChain}[0].${chain}` : `${parentChain}.${chain}`;
  1010. return chain;
  1011. },
  1012. // 显示脑图
  1013. show: function(json2) {
  1014. let isArr = Array.isArray(json2);
  1015. if (isArr) {
  1016. if (typeof json2[0] !== "object") {
  1017. layer.msg("数据结构无法生成脑图", { time: 1e3 });
  1018. return this;
  1019. }
  1020. json2 = Utils.findMaxKeysObject(json2);
  1021. }
  1022. if (!this.isFirst) {
  1023. return this;
  1024. }
  1025. _unsafeWindow.GLOBAL_JSMIND.show({
  1026. meta: {
  1027. name: "JSON脑图",
  1028. author: "1220301855@qq.com",
  1029. version: "1.0"
  1030. },
  1031. format: "node_tree",
  1032. /* 数据内容 */
  1033. data: {
  1034. id: "root",
  1035. topic: "Response",
  1036. direction: "left",
  1037. children: this.convert(json2),
  1038. chain: isArr ? "Response[0]" : "Response"
  1039. }
  1040. });
  1041. this.isFirst = false;
  1042. return this;
  1043. },
  1044. // 脑图节点事件
  1045. event: function() {
  1046. const jsonMind2 = this;
  1047. $("jmnode").on("dblclick mouseover mouseout", function(event) {
  1048. const that2 = $(this), node = _unsafeWindow.GLOBAL_JSMIND.get_node(that2.attr("nodeid"));
  1049. if (!node.parent) {
  1050. return;
  1051. }
  1052. switch (event.type) {
  1053. case "dblclick":
  1054. _GM_setClipboard(jsonMind2.mindChain(node));
  1055. layer.msg("节点路径复制成功", { time: 1500 });
  1056. break;
  1057. case "mouseover":
  1058. const s = `<b>节点路径(双击复制)</b><br/>${jsonMind2.mindChain(node)}`;
  1059. layer.tips(s, that2, {
  1060. time: 0,
  1061. tips: [2, "#2e59a7"]
  1062. });
  1063. break;
  1064. default:
  1065. layer.closeAll();
  1066. break;
  1067. }
  1068. });
  1069. return this;
  1070. },
  1071. init: function(json2) {
  1072. if (!_unsafeWindow.GLOBAL_JSMIND) {
  1073. _unsafeWindow.GLOBAL_JSMIND = new jsMind({
  1074. mode: "side",
  1075. editable: false,
  1076. container: "jmContainer",
  1077. view: {
  1078. hmargin: 50,
  1079. // 思维导图距容器外框的最小水平距离
  1080. vmargin: 50,
  1081. // 思维导图距容器外框的最小垂直距离
  1082. engine: "svg",
  1083. // 思维导图各节点之间线条的绘制引擎
  1084. draggable: true,
  1085. // 当容器不能完全容纳思维导图时,是否允许拖动画布代替鼠标滚动
  1086. support_html: false,
  1087. line_color: "#C4C9D0"
  1088. },
  1089. zoom: {
  1090. // 配置缩放
  1091. min: 0.1,
  1092. // 最小的缩放比例
  1093. max: 2.1,
  1094. // 最大的缩放比例
  1095. step: 0.1
  1096. // 缩放比例间隔
  1097. },
  1098. layout: {
  1099. vspace: 7,
  1100. // 节点之间的垂直间距
  1101. hspace: 150
  1102. // 节点之间的水平空间
  1103. }
  1104. });
  1105. }
  1106. this.show(json2).event();
  1107. }
  1108. };
  1109. const tabsEvent = {
  1110. firstFormat: true,
  1111. isBeautify: false,
  1112. $rawText: $("#rawTextContainer"),
  1113. /**
  1114. * 保存为文件
  1115. */
  1116. download: {
  1117. download: function(content, filename) {
  1118. const link = document.createElement("a");
  1119. link.href = content;
  1120. link.download = filename;
  1121. link.click();
  1122. },
  1123. saveJSON: function(text2) {
  1124. const blob = new Blob([text2], { type: "text/plain;charset=utf-8" });
  1125. const url = URL.createObjectURL(blob);
  1126. const filename = (/* @__PURE__ */ new Date()).getTime() + ".json";
  1127. this.download(url, filename);
  1128. URL.revokeObjectURL(url);
  1129. },
  1130. savePNG: () => _unsafeWindow.GLOBAL_JSMIND.shoot()
  1131. },
  1132. saveJson: function() {
  1133. if ($("#jmContainer").is(":visible")) {
  1134. this.download.savePNG();
  1135. } else {
  1136. this.download.saveJSON(this.$rawText.text());
  1137. }
  1138. },
  1139. // 复制JSON文本内容
  1140. copyJson: function() {
  1141. _GM_setClipboard(this.$rawText.text());
  1142. layer.msg("复制成功", { time: 1500 });
  1143. },
  1144. // 全部折叠
  1145. collapseAll: function() {
  1146. if ($("#formatContainer").is(":visible")) {
  1147. try {
  1148. $("a.json-toggle").not(".collapsed").click();
  1149. } catch (e) {
  1150. }
  1151. } else {
  1152. _unsafeWindow.GLOBAL_JSMIND.collapse_all();
  1153. }
  1154. },
  1155. // 全部展开
  1156. expandAll: function() {
  1157. if ($("#formatContainer").is(":visible")) {
  1158. try {
  1159. $("a.json-placeholder").click().remove();
  1160. } catch (e) {
  1161. }
  1162. } else {
  1163. _unsafeWindow.GLOBAL_JSMIND.expand_all();
  1164. _unsafeWindow.GLOBAL_JSMIND.scroll_node_to_center(_unsafeWindow.GLOBAL_JSMIND.get_root());
  1165. }
  1166. },
  1167. format: function() {
  1168. },
  1169. // 显示JSON脑图
  1170. viewJsonMind: function() {
  1171. jsonMind.init(_unsafeWindow.GLOBAL_JSON);
  1172. _unsafeWindow.GLOBAL_JSMIND.scroll_node_to_center(_unsafeWindow.GLOBAL_JSMIND.get_root());
  1173. },
  1174. // 查看原始JSON内容
  1175. viewRawText: function() {
  1176. if (this.firstFormat) {
  1177. this.$rawText.html(_unsafeWindow.GLOBAL_SOURCE_ELEMENT.clone());
  1178. this.firstFormat = false;
  1179. }
  1180. },
  1181. // 美化
  1182. beautify: function() {
  1183. this.isBeautify = !this.isBeautify;
  1184. if (this.isBeautify) {
  1185. let str = JSON.stringify(_unsafeWindow.GLOBAL_JSON, null, 2);
  1186. if (_unsafeWindow.GLOBAL_JSONP_FUN !== void 0 && _unsafeWindow.GLOBAL_JSONP_FUN !== null) {
  1187. str = `${_unsafeWindow.GLOBAL_JSONP_FUN}(${str})`;
  1188. }
  1189. this.$rawText.find("pre").text(str);
  1190. } else {
  1191. this.$rawText.html(_unsafeWindow.GLOBAL_SOURCE_ELEMENT.clone());
  1192. }
  1193. },
  1194. jsoncrack: function() {
  1195. layer.closeAll();
  1196. const index = layer.open({
  1197. type: 1,
  1198. title: false,
  1199. maxmin: true,
  1200. shadeClose: true,
  1201. area: ["900px", "600px"],
  1202. content: '<iframe style="width: 100%;height: 100%;border: 0;" id="jsoncrackEmbed" src="https://jsoncrack.feny.ink/widget"></iframe>',
  1203. success: function(layero) {
  1204. const jsonCrackEmbed = layero.find("#jsoncrackEmbed")[0];
  1205. window == null ? void 0 : window.addEventListener("message", () => {
  1206. jsonCrackEmbed.contentWindow.postMessage(
  1207. {
  1208. json: JSON.stringify(_unsafeWindow.GLOBAL_JSON)
  1209. },
  1210. "*"
  1211. );
  1212. });
  1213. }
  1214. });
  1215. layer.full(index);
  1216. },
  1217. init: function() {
  1218. this.viewRawText();
  1219. $(".btn").on("click", (e) => {
  1220. const target = e.target, id = target.id;
  1221. if (target.classList.contains("tabs-item")) {
  1222. const index = $(target).index();
  1223. $(target).addClass("active").siblings().removeClass("active");
  1224. $(".tabs-container > div").removeClass("active").eq(index).addClass("active");
  1225. const beautifyEl = $("#beautify"), searchEl = $(".searchbox"), copyJsonEl = $("#copyJson"), jsoncrackEl = $("#jsoncrack"), aEl = $("#collapseAll, #expandAll");
  1226. id === "format" ? searchEl.show() : searchEl.hide();
  1227. id === "viewJsonMind" ? copyJsonEl.hide() && jsoncrackEl.show() : copyJsonEl.show() && jsoncrackEl.hide();
  1228. id === "viewRawText" ? beautifyEl.show() && aEl.hide() : beautifyEl.hide() && aEl.show();
  1229. }
  1230. this[id](target);
  1231. });
  1232. return this;
  1233. }
  1234. };
  1235. window.addEventListener("message", function(event) {
  1236. const { data } = event;
  1237. if (data && data.reload) {
  1238. jsonMind.isFirst = true;
  1239. jsonMind.init(_unsafeWindow.GLOBAL_JSON);
  1240. tabsEvent.isBeautify = false;
  1241. tabsEvent.$rawText.html(_unsafeWindow.GLOBAL_SOURCE_ELEMENT.clone());
  1242. }
  1243. });
  1244. const jsonFilter = {
  1245. // 过滤 JSON
  1246. filterJSON: function(filter) {
  1247. const style = _GM_getValue("formatStyle") || "default";
  1248. if (!filter) {
  1249. style == "default" ? $("#formatContainer li").removeClass("hidden") : $(".json-key").parent().removeClass("hidden");
  1250. return;
  1251. }
  1252. const chainSet = /* @__PURE__ */ new Set();
  1253. document.querySelectorAll("#formatContainer *[json-path]").forEach((el) => {
  1254. let chain = $(el).attr("json-path");
  1255. if (!chain) {
  1256. return;
  1257. }
  1258. const newChain = chain.substr(chain.lastIndexOf("."));
  1259. if (!newChain.toLowerCase().includes(filter.toLowerCase())) {
  1260. return;
  1261. }
  1262. chainSet.add(chain);
  1263. while (chain = chain.substr(0, chain.lastIndexOf("."))) {
  1264. chainSet.add(chain);
  1265. }
  1266. });
  1267. document.querySelectorAll(
  1268. "#formatContainer *[class*='json-']:not([class*='json-key']):not([class*='json-brackets'])"
  1269. ).forEach((el) => {
  1270. const target = $(el);
  1271. let chain = style == "default" ? target.parent().attr("json-path") : target.siblings(".json-key").attr("json-path");
  1272. if (!chain) {
  1273. return;
  1274. }
  1275. const text2 = target.text();
  1276. if (!text2.toLowerCase().includes(filter.toLowerCase())) {
  1277. return;
  1278. }
  1279. chainSet.add(chain);
  1280. while (chain = chain.substring(0, chain.lastIndexOf("."))) {
  1281. chainSet.add(chain);
  1282. }
  1283. });
  1284. style == "default" ? $("#formatContainer li").addClass("hidden") : $(".json-key").parent().addClass("hidden");
  1285. chainSet.forEach((chain) => {
  1286. style == "default" ? $(`#formatContainer *[json-path="${chain}"]`).removeClass("hidden") : $(`#formatContainer *[json-path="${chain}"]`).parent().removeClass("hidden");
  1287. });
  1288. },
  1289. // JSON 过滤
  1290. input: function() {
  1291. const that2 = this;
  1292. $("input").on("input", function() {
  1293. const val = $(this).val();
  1294. val === "" ? $(".clear").attr("hidden", true) : $(".clear").attr("hidden", false);
  1295. that2.filterJSON(val);
  1296. });
  1297. return that2;
  1298. },
  1299. // 清空输入框内容
  1300. clear: function() {
  1301. const that2 = this;
  1302. $(".clear").click(function() {
  1303. that2.filterJSON();
  1304. $("input").val("");
  1305. $(this).attr("hidden", true);
  1306. });
  1307. return this;
  1308. },
  1309. init: function() {
  1310. this.input().clear();
  1311. }
  1312. };
  1313. const theme = {
  1314. // 切换主题
  1315. changeTheme: function() {
  1316. const that2 = this;
  1317. $(".theme select").on("change", function(e) {
  1318. const val = $(e.target).val();
  1319. _GM_setValue("theme", val);
  1320. that2.setTheme();
  1321. });
  1322. return this;
  1323. },
  1324. // 设置主题
  1325. setTheme: function() {
  1326. const theme2 = _GM_getValue("theme") || "default";
  1327. $("body").removeClass().addClass(theme2);
  1328. $(".theme select").val(theme2);
  1329. return this;
  1330. },
  1331. init: function() {
  1332. this.setTheme().changeTheme();
  1333. }
  1334. };
  1335. const tools = {
  1336. inputJson: function() {
  1337. const that = this;
  1338. $(".inputJson").off("click").on("click", function() {
  1339. layer.prompt(
  1340. {
  1341. title: "JSON 输入",
  1342. formType: 2,
  1343. shadeClose: true,
  1344. maxlength: 1e6
  1345. },
  1346. function(text) {
  1347. if (!text) {
  1348. layer.msg("内容不能为空", { time: 1500 });
  1349. return;
  1350. }
  1351. const rawText = text, oldJSONPFun = _unsafeWindow.GLOBAL_JSONP_FUN;
  1352. const match = text.match(/^([^\s(]*)\s*\(([\s\S]*)\)\s*;?$/);
  1353. if (match && match[1] && match[2]) {
  1354. _unsafeWindow.GLOBAL_JSONP_FUN = match[1];
  1355. text = match[2];
  1356. }
  1357. try {
  1358. const json = JSON.parse(JSON.stringify(eval(`(${text})`)));
  1359. that.reload(json, rawText);
  1360. } catch (e) {
  1361. console.log(e);
  1362. _unsafeWindow.GLOBAL_JSONP_FUN = oldJSONPFun;
  1363. layer.msg("JSON不合法", { time: 1500 });
  1364. }
  1365. }
  1366. );
  1367. });
  1368. return this;
  1369. },
  1370. fetchApi: function() {
  1371. const that2 = this;
  1372. $(".fetchApi").off("click").on("click", function() {
  1373. layer.open({
  1374. type: 1,
  1375. closeBtn: 0,
  1376. //不显示关闭按钮
  1377. shadeClose: true,
  1378. //开启遮罩关闭
  1379. title: "HTTP 请求",
  1380. content: `<form class="httpRequest">
  1381. <div class="requestbox">
  1382. <select name="method">
  1383. <option value="POST">POST</option>
  1384. <option value="GET">GET</option>
  1385. <option value="PUT">PUT</option>
  1386. <option value="DELETE">DELETE</option>
  1387. </select>
  1388. <input name="url" placeholder="请求地址" />
  1389. <select name="contentType">
  1390. <option value="application/x-www-form-urlencoded;charset=UTF-8">urlencoded</option>
  1391. <option value="application/json;charset=UTF-8">application/json</option>
  1392. </select>
  1393. <button type="submit">发送</button>
  1394. </div>
  1395. <div class="textarea">
  1396. <input name="headers" placeholder='请求头 {"token": "test"}' />
  1397. <input name="params" placeholder='请求参数 {"id": "test", ""name": "test"}' />
  1398. </div>
  1399. </form>`
  1400. });
  1401. $("form").on("submit", function(event) {
  1402. event.preventDefault();
  1403. const serialize = $(this).serializeArray();
  1404. const form = {};
  1405. for (const key in serialize) {
  1406. const it = serialize[key];
  1407. form[it.name] = it.value;
  1408. }
  1409. if (form.url === "") {
  1410. layer.msg("请求URL不能为空");
  1411. return;
  1412. }
  1413. let headers = form.headers;
  1414. let params = form.params;
  1415. try {
  1416. if (headers) {
  1417. headers = JSON.parse(headers);
  1418. }
  1419. } catch (e) {
  1420. layer.msg("请求头格式不合法");
  1421. return;
  1422. }
  1423. try {
  1424. if (params) {
  1425. params = JSON.parse(params);
  1426. }
  1427. } catch (e) {
  1428. layer.msg("请求参数格式不合法");
  1429. return;
  1430. }
  1431. layer.load(0, { shade: false });
  1432. $.ajax({
  1433. url: "https://fetch-api.feny.ink/httpRequest",
  1434. type: "POST",
  1435. data: JSON.stringify(form),
  1436. contentType: "application/json"
  1437. }).then(
  1438. (response) => {
  1439. _unsafeWindow.GLOBAL_JSONP_FUN = null;
  1440. that2.reload(response, JSON.stringify(response));
  1441. },
  1442. (error) => {
  1443. layer.closeAll();
  1444. console.log(error);
  1445. }
  1446. );
  1447. });
  1448. });
  1449. return this;
  1450. },
  1451. reload: function(json2, rawText2) {
  1452. _unsafeWindow.GLOBAL_JSON = json2;
  1453. _unsafeWindow.GLOBAL_SOURCE_ELEMENT.text(rawText2);
  1454. window.postMessage({ reload: true });
  1455. layer.closeAll();
  1456. },
  1457. init: function() {
  1458. this.inputJson().fetchApi();
  1459. }
  1460. };
  1461. tabsEvent.init();
  1462. jsonFilter.init();
  1463. theme.init();
  1464. tools.init();
  1465.  
  1466. })
  1467. };
  1468. }));
  1469.  
  1470. System.register("./index-Cgl7hcfy-DaTAQqy4.js", ['jquery'], (function (exports, module) {
  1471. 'use strict';
  1472. var $;
  1473. return {
  1474. setters: [module => {
  1475. $ = module.default;
  1476. }],
  1477. execute: (function () {
  1478.  
  1479. $(document.body).append('<div class="scroll-top"></div>').find(".tabs-container").on("scroll", function(e) {
  1480. const scrollTop = $(this).scrollTop();
  1481. scrollTop > 500 ? $(".scroll-top").fadeIn() : $(".scroll-top").fadeOut();
  1482. }).parents().find(".scroll-top").on("click", function() {
  1483. $(".tabs-container").animate(
  1484. {
  1485. scrollTop: "0"
  1486. },
  1487. 1e3
  1488. );
  1489. });
  1490.  
  1491. })
  1492. };
  1493. }));
  1494.  
  1495. System.import("./__entry.js", "./");

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址