JSON Viewer

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

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

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