JSON Viewer

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

目前为 2024-10-15 提交的版本。查看 最新版本

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