JSON Viewer

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

当前为 2024-10-13 提交的版本,查看 最新版本

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

QingJ © 2025

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