FuckEducoder

解除头歌复制粘贴限制,针对UVA算法题目自动填充答案,设置随机测试时间

目前为 2023-11-29 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name FuckEducoder
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.5
  5. // @description 解除头歌复制粘贴限制,针对UVA算法题目自动填充答案,设置随机测试时间
  6. // @author SunSeaLucky
  7. // @match https://www.educoder.net/tasks/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant none
  10. // @require https://cdn.jsdelivr.net/npm/js-base64@3.7.5/base64.min.js
  11. // @connect service-q3vdttin-1301163996.bj.apigw.tencentcs.com
  12. // @run-at document-start
  13. // @license MIT
  14. // ==/UserScript==
  15.  
  16. const max = 30000;
  17. const min = 5000;
  18.  
  19. const requestError = "//RequestError: May this time serve is closed! Try again at another time.";
  20.  
  21. // 目前设置随机时间的方法出现严重Bug,请谨慎使用!
  22. // 若仍想快速刷时间,请进入微信头歌小程序,在对应的实例界面左右滑动,可快速刷到int最大值
  23. const setRandomTime = false;
  24.  
  25. (function () {
  26. 'use strict';
  27. let oldFetch = fetch;
  28. function hookFetch(...args) {
  29. return new Promise((resolve, reject) => {
  30. oldFetch.apply(this, arguments).then((response) => {
  31. if (arguments[0].indexOf('homework_common_id') !== -1) {
  32. const oldJson = response.json;
  33. response.json = function () {
  34. return new Promise((resolve, reject) => {
  35. oldJson.apply(this, arguments).then((result) => {
  36. if (setRandomTime) result.game.cost_time = Math.floor(Math.random() * (max - min + 1)) + min;
  37. result.shixun.forbid_copy = false;
  38. result.shixun.vip = true;
  39. resolve(result);
  40. });
  41. });
  42. };
  43. } else if (arguments[0].indexOf('rep_content') !== -1 && arguments[0].indexOf('tasks') !== -1) {
  44. const oldJson = response.json;
  45. response.json = function () {
  46. return new Promise((resolve, reject) => {
  47. oldJson.apply(this, arguments).then((result) => {
  48. let pattern = /uva(.*)\./,
  49. str = result.filename;
  50.  
  51. let url = "https://service-q3vdttin-1301163996.bj.apigw.tencentcs.com/release/FuckEducoder?question=" + pattern.exec(str)[1] + "&vertification=DLloIbnmoTpobbpg6gKdm9pZCBwaWxlX29udG8oaW50IHAsIG"
  52.  
  53. requsets(url)
  54. .then(res => {
  55. //TODO if this request cannot return any text, user can't input or view the code UI too.
  56. result.content.content = JSON.parse(res).data;
  57. resolve(result);
  58. })
  59. });
  60. });
  61. };
  62. }
  63. resolve(response);
  64. });
  65. });
  66. }
  67.  
  68. window.fetch = hookFetch;
  69.  
  70. async function requsets(url) {
  71. try {
  72. const response = await fetch(url, { method: "POST" });
  73. return await response.text();
  74. } catch (error) {
  75. return Base64.encode(requestError);
  76. }
  77. }
  78. })();
  79.