Json2Blob

导入导出json到blob

目前為 2022-09-16 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Json2Blob
  3. // @namespace http://firefoxcn.net/
  4. // @description 导入导出json到blob
  5. // @version 0.1
  6. // @author Dniness
  7. // @match https://greasyfork.org/*
  8. // @grant none
  9. // @license GPL License
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14. let e = document.getElementById("install-area");
  15. e&&fetch(e.firstElementChild).then(e=>e.text()).then(e=>{
  16. let div = document.getElementById("install-area");
  17. e = eval(e);
  18. let html = Object.keys(e);
  19. html.forEach(c=>{e[c]=JSON.stringify(e[c])});
  20. div.array = e ;
  21. e = div.fun = e =>{
  22. let x = div.array[e.options[e.selectedIndex].value];
  23. x = new Blob([x], {type: 'text/plain'});
  24. x = URL.createObjectURL(x);
  25. e.outerHTML = '<a href="'+x+'" target="_blank">右键复制</a>';
  26. }
  27. html.unshift('<select onChange="this.parentNode.fun(this)"><option style="display:none">存在数组引用');
  28. div.innerHTML+=html.join('</option><option>');
  29. }).catch(e=>console.log('not objects of json'));
  30. })();