Json2Blob

导入导出json到blob

当前为 2022-09-16 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Json2Blob
  3. // @namespace http://firefoxcn.net/
  4. // @description 导入导出json到blob
  5. // @version 0.3
  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&&e.fun&&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. return {
  31. HeaderEditorCORS:{
  32. "request": [
  33. {
  34. "enable": true,
  35. "name": "跨域js外链式",
  36. "ruleType": "redirect",
  37. "matchType": "prefix",
  38. "pattern": "https://0.0.0.0/fetch.js?",
  39. "exclude": "",
  40. "group": "跨域length128",
  41. "isFunction": true,
  42. "action": "redirect",
  43. "code": "return `data:,(${o=>{\nconst fetch = o.fetch;\no.fetch = (url,opt='')=>(opt.headers = {\n\t\tAccept:(e=>\n\t\t\te.forEach((a,i)=>\n\t\t\t\te[i]=a.join(';')\n\t\t\t)||'-X;-'+e.join(';-')\n\t\t)(Object.entries(opt.headers||''))\n\t})&&fetch(url,opt||opt.o)\n}})(${val.split('?').pop()||'this'})`;"
  44. }
  45. ],
  46. "sendHeader": [
  47. {
  48. "enable": true,
  49. "name": "复杂跨域绕过预检",
  50. "ruleType": "modifySendHeader",
  51. "matchType": "all",
  52. "pattern": "",
  53. "exclude": "",
  54. "group": "跨域length128",
  55. "isFunction": true,
  56. "code": "val.forEach(e=>\ne.name.toLowerCase() === 'accept'&&\ne.value.startsWith('-X;-')?(e.value=\ne.value.split(';-').slice(1).forEach(e=>{let i = e.indexOf(';');\nval.push({\"name\": e.slice(0,i), \"value\": e.slice(1+i)})})||' */*; q=0.01'):\ne.name.toLowerCase() === 'referer'?(e.value=''):\ne.name.toLowerCase() === 'origin'?(e.name = \"H-Referer-Origin\"):0);"
  57. }
  58. ],
  59. "receiveHeader": [
  60. {
  61. "enable": true,
  62. "name": "跨域访问许可",
  63. "ruleType": "modifyReceiveHeader",
  64. "matchType": "all",
  65. "pattern": "",
  66. "exclude": "",
  67. "group": "跨域length128",
  68. "isFunction": true,
  69. "code": "const H={name:\"H-Referer-Origin\"};\ndetail.originUrl&&((S = new Set())=>{ top[H.name] = S ; H.value = \nS.has(detail.id)?'null':detail.originUrl.split('/').slice(0,3).join('/');\nS[(detail.statusCode&0740)===0440?'add':'delete'](detail.id);\n})(top[H.name] );\n(detail.Referer= (detail.requestHeaders||[H]).find(e=>e.name==H.name))&&\n!val.forEach(e=>e.name.toLowerCase()===\"location\"?e.value[4]==':'&&\n(e.value = detail.url.split(':')[0]+e.value.slice(4)):\n(e.name.toLowerCase().startsWith(\"access-control-allow-\")&&e).name+=\"-X\")&&\nval.push({\"name\": \"Access-Control-Allow-Origin\", \"value\":detail.Referer.value})&&\nval.push({\"name\": \"Access-Control-Allow-Credentials\", \"value\": \"true\"})&&\nval.push({\"name\": \"Access-Control-Allow-Headers\", \"value\":detail.Referer.name})&&\nval.push({\"name\": \"Access-Control-Allow-Methods\", \"value\": \"POST,GET,OPTIONS,DELETE\"}); "
  70. }
  71. ],
  72. "receiveBody": []
  73. }
  74. }
  75. })();