JSON Viewer

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

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

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