🏠 Home 

LEORChn-Helper

DO NOT TRUST - Dynamic link library for permission elevation at leorchn.github.io


Install this script?
  1. // ==UserScript==
  2. // @name LEORChn-Helper
  3. // @name:zh-CN 瑞兽谷辅助脚本
  4. // @description DO NOT TRUST - Dynamic link library for permission elevation at leorchn.github.io
  5. // @description:zh-CN 请 勿 安 装!- 瑞兽谷扩展功能包,用于提权实现相应功能。
  6. // @include https://leorchn.github.io/workshop/*
  7. // @include https://127.0.0.1:1101/workshop/*
  8. // @include https://127.0.0.1:81/workshop/*
  9. // @namespace https://greasyfork.org/users/159546
  10. // @version 1.0
  11. // @author LEORChn
  12. // @run-at document-end
  13. // @grant GM_xmlhttpRequest
  14. // @connect gateway.live-a-hero.jp
  15. // @connect raw.githubusercontent.com
  16. // @connect d1itvxfdul6wxg.cloudfront.net
  17. // @connect baidu.com
  18. // @connect bilibili.com
  19. // ==/UserScript==
  20. unsafeWindow['http'] = http;
  21. unsafeWindow['httpj'] = httpj;
  22. try{
  23. unsafeWindow.onHelperMain();
  24. }catch(e){}
  25. function http(){
  26. var args = Array.prototype.slice.call(arguments);
  27. if(args.length == 1 && args[0] instanceof Array) args = args[0];
  28. var pointer = 0,
  29. method, url, headers, formdata, dofun, dofail, onprogress,
  30. responseType = '';
  31. args.forEach(function(e){
  32. switch(pointer){
  33. case 0:
  34. e = e.split(' ', 2); // 允许在第一个参数中用空格将 http-method 与 url 隔开,而省去 引号+逗号+引号 的麻烦
  35. method = e[0].toUpperCase();
  36. if(e.length > 1){
  37. pointer++; // 偏移到下一个
  38. e = e[1];
  39. }else break;
  40. case 1: url = e; break;
  41. case 2:
  42. case 3:
  43. if(e instanceof Function){ // 允许不添加 http-body 而直接撰写行为。
  44. pointer = 4; // 偏移到function
  45. }else{
  46. if(pointer == 2)
  47. headers = e;
  48. else if(pointer == 3)
  49. formdata = e;
  50. break;
  51. }
  52. case 4:
  53. if(e.name == 'ArrayBuffer'){
  54. responseType = 'arraybuffer';
  55. break;
  56. }else pointer++;
  57. case 5: dofun = e; break;
  58. case 6: dofail = e; break;
  59. case 7: onprogress = e;
  60. }
  61. pointer++;
  62. });
  63. console.log('%c'+method+' '+url+(headers? '\n'+headers: '')+(formdata? '\n\n'+formdata: ''), 'color:#ccc');
  64. GM_xmlhttpRequest({
  65. method: method,
  66. url: url,
  67. data: formdata,
  68. headers: getHeaders(headers),
  69. responseType: responseType,
  70. onload: dofun,
  71. onerror: dofail
  72. });
  73. }
  74. function pl(s){console.log(s);}
  75. function httpj(){
  76. var args = Array.prototype.slice.call(arguments);
  77. var originFunction;
  78. for(var i=0; i<args.length; i++){
  79. if(!(args[i] instanceof Function)) continue;
  80. originFunction = args[i];
  81. args[i] = function(){
  82. var j,
  83. stat = this.status,
  84. resp = this.responseText;
  85. try{
  86. j = JSON.parse(resp || '{}');
  87. }catch(e){console.debug('json cannot parse?\n' + j);}
  88. if(Array.isArray(j)) // JSON Array
  89. j = { httpstat:stat, data:j }
  90. else if(j instanceof Object) // JSON Object
  91. j.httpstat = stat;
  92. else // Nothing, text/plain
  93. j = { httpstat:stat, data:resp }
  94. originFunction(j);
  95. };
  96. break;
  97. }
  98. http(args);
  99. }
  100. function getHeaders(t){
  101. var obj = {};
  102. if(!t) return obj;
  103. t.split('\n').forEach(function(e){
  104. var res, reg = /\s*(\S+)\s*:\s*(.*)/;
  105. if((res = reg.exec(e)) == null) return;
  106. obj[res[1]] = res[2];
  107. });
  108. return obj;
  109. }