I'm wenku8 admin!

通过简单的几行代码把用户伪装成wenku8管管

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/428403/1000865/I%27m%20wenku8%20admin%21.js

  1. (function () {
  2. const targetPage = 'https://www.wenku8.net/userinfo.php?id=917768';
  3. const scriptId = 'pretend_admin';
  4. const imgId = 'pretend_admin_img';
  5. const scriptLink = 'https://gf.qytechs.cn/scripts/428403/code/script.js';
  6. main();
  7.  
  8. function main() {
  9. const img = document.querySelector('#' + imgId);
  10. img && img.parentElement.removeChild(img);
  11.  
  12. switch(location.href) {
  13. case 'about:blank':
  14. console.log('Wenku8 admin: Injecting to opener...');
  15. // Opened page: Inject to opener
  16. const oDoc = window.opener.document;
  17. const script = oDoc.querySelector(scriptId);
  18. loadJS(script.src, null, oDoc);
  19. case targetPage:
  20. // Just this page
  21. console.log('Wenku8 admin: Editing page...');
  22. getDocument('https://www.wenku8.net/userinfo.php?id=2', function (oDoc) {
  23. const content = document.querySelector('#content');
  24. const table = content.querySelector('table');
  25. const oContent = oDoc.querySelector('#content');
  26. const otable = oContent.querySelector('table');
  27. content.innerHTML = oContent.innerHTML;
  28. });
  29. default:
  30. // Opener page: Make all opener links magical
  31. console.log('Wenku8 admin: Doing magic...');
  32. if (window.magical) {
  33. return false;
  34. }
  35. window.magical = true;
  36. const as = document.querySelectorAll('a[href="https://www.wenku8.net/userinfo.php?id=917768"]');
  37. for (const a of as) {
  38. a.addEventListener('click', function (e) {
  39. destroyEvent(e);
  40. const newtab = window.open(a.href);
  41. const oWin = newtab.window;
  42. const oDom = newtab.document;
  43. oWin.addEventListener('load', function(e) {
  44. const win = e.currentTarget;
  45. const dom = win.document;
  46. const script = dom.createElement('script');
  47. script.src = scriptLink;
  48. dom.head.appendChild(script);
  49. });
  50. });
  51. }
  52. }
  53. return true;
  54. }
  55.  
  56. // Load javascript from given url
  57. function loadJS(url, callback, oDoc = document) {
  58. var script = document.createElement('script'),
  59. fn = callback || function () {};
  60. script.type = 'text/javascript';
  61. //IE
  62. if (script.readyState) {
  63. script.onreadystatechange = function () {
  64. if (script.readyState == 'loaded' || script.readyState == 'complete') {
  65. script.onreadystatechange = null;
  66. fn();
  67. }
  68. };
  69. } else {
  70. //其他浏览器
  71. script.onload = function () {
  72. fn();
  73. };
  74. }
  75. script.src = url;
  76. oDoc.getElementsByTagName('head')[0].appendChild(script);
  77. }
  78.  
  79. // Download and parse a url page into a html document(dom).
  80. // when xhr onload: callback.apply([dom, args])
  81. function getDocument(url, callback, args = []) {
  82. const xhr = new XMLHttpRequest();
  83. xhr.open('GET', url, true);
  84. xhr.responseType = 'blob';
  85. xhr.onload = function (response) {
  86. const htmlblob = xhr.response;
  87. const reader = new FileReader();
  88. reader.onload = function (e) {
  89. const htmlText = reader.result;
  90. const dom = new DOMParser().parseFromString(htmlText, 'text/html');
  91. args = [dom].concat(args);
  92. callback.apply(null, args);
  93. //callback(dom, htmlText);
  94. }
  95. reader.readAsText(htmlblob, 'GBK');
  96. }
  97. xhr.send();
  98. }
  99.  
  100. // Just stopPropagation and preventDefault
  101. function destroyEvent(e) {
  102. if (!e) {return false;};
  103. if (!e instanceof Event) {return false;};
  104. e.stopPropagation();
  105. e.preventDefault();
  106. }
  107. }) ();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址