JSON Viewer

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

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

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