config.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. let labels = ["<a href='https://jamesfengcao.codeberg.page/zh/redirect/index.html'>全局重定向网址</a>","下载目录(选项'下载至可卸存储'下生效)","网页默认字体族","cursive字体族","Fantasy字体族","Fixed字体族","Sans-Serif字体族","Serif字体族"];
  2. let names = ["redirecturl","downloadpath","font","cursive","fantasy","fixed","sansserif","serif"];
  3. let d=document;
  4. let sa = [`<head><meta charset="utf-8"><meta name="viewport" content="width=device-width" /></head><style>input{height:40px;width:100%;border-radius:50px;}</style>
  5. <datalist id="family">
  6. <option value="sans-serif">
  7. <option value="sans-serif-condensed">
  8. <option value="sans-serif-smallcaps">
  9. <option value="serif">
  10. <option value="serif-monospace">
  11. <option value="monospace">
  12. <option value="cursive">
  13. </datalist>
  14. <script>
  15. function save(){
  16. let d=document;let f=d.forms[0];
  17. let inputs = Array.from(f.querySelectorAll('input')).map(input => input.value);
  18. inputs.pop();
  19. inputs.push('<script charset="utf-8" type="application/javascript" src="https://gitee.com/jamesfengcao/uweb/raw/master/zh/searchurl/config.js#"><\\/script>');
  20. let str = inputs.join('\\n');
  21. let url = 'i:b1保存配置%0A%0Ai:8lconfig.html%0Ai:0lconfig.html:'+btoa(str);
  22. d.location.href=url;
  23. return false;
  24. }
  25. </script>
  26. <form onsubmit="return save()" accept-charset=utf-8 >`];
  27. function gen(text) {
  28. let strs = text.split('\n');
  29. let i;
  30. for (i=0; i<2; i++)
  31. sa.push("<label>"+labels[i]+"<input type='text' name='"+names[i]+"' value='"+strs[i]+"'/></label>");
  32. for (i = 2; i < labels.length; i++){
  33. sa.push("<label>"+labels[i]+"<input list='family' type='text' name='"+names[i]+"' value='"+strs[i]+"'/></label>");
  34. }
  35. sa.push('<input type="submit" value="Save"></form>');
  36. let r = sa.join('<br>');
  37. d.write(r);
  38. d.close();
  39. }
  40. if(d.body){
  41. var r=new XMLHttpRequest;
  42. r.onload=function(){
  43. var t=r.responseText;
  44. gen(t);
  45. }
  46. r.open("GET",location.href,!0);
  47. r.send(null);
  48. }else {
  49. let text = "\n".repeat(labels.length-1);
  50. gen(text);
  51. }