进化(Evolve)自定义倍速

通过劫持Worker.prototype.postMessage方法进行加速

  1. // ==UserScript==
  2. // @name 进化(Evolve)自定义倍速
  3. // @version 1.1.1
  4. // @description 通过劫持Worker.prototype.postMessage方法进行加速
  5. // @author DreamNya
  6. // @match https://g8hh.github.io/evolve/
  7. // @icon https://www.google.com/s2/favicons?sz=64&domain=github.io
  8. // @grant none
  9. // @license MIT
  10. // @run-at document-start
  11. // @namespace https://gf.qytechs.cn/users/809466
  12. // ==/UserScript==
  13. /* eslint-env jquery */
  14. /*
  15. 更新说明
  16. v1.1.1(2022-08-03):
  17. 优化代码
  18.  
  19. v1.1(2022-08-03):
  20. 现在支持游戏内动态调整倍速
  21. 初始默认1倍速,点击游戏右上角版本号左边可动态调整游戏倍速
  22. 且脚本会自动存储当前倍数到localStorage中,下次进入游戏会自动读取
  23. 如有bug欢迎反馈
  24. */
  25.  
  26. const getValue = function (key, defaultValue) {
  27. let value = JSON.parse(window.localStorage.getItem(key))
  28. return value || defaultValue
  29. }
  30.  
  31. const setValue = function (key, value) {
  32. window.localStorage.setItem(key, JSON.stringify(value))
  33. }
  34.  
  35. let customSpeed = getValue("customSpeed", 1); //不需要手动修改,初始1倍速度,点击游戏右上角版本号左边可动态自定义倍速并储存,下次进入游戏自动读取
  36.  
  37. let fromScript = false;
  38. let vueMethod;
  39.  
  40. const oldPost = Worker.prototype.postMessage;
  41. Worker.prototype.postMessage = async function (...args) {
  42. let that = this
  43. async function hookPost(){
  44. if (args[0].period) {
  45. args[0].period = args[0].period / customSpeed
  46. }
  47. oldPost.apply(that, args)
  48. }
  49. let hookResult = await hookPost()
  50. if (fromScript) {
  51. vueMethod.pause()
  52. fromScript = false
  53. }
  54. return hookResult
  55. }
  56.  
  57. let timer = setInterval(() => {
  58. if (typeof $ == "function" && $("#versionLog").length > 0) {
  59. clearInterval(timer)
  60. $("#versionLog").before(`<span id="customSpeed" class="version">自定义倍速</span>`)
  61. $("#customSpeed").text("自定义倍速x" + customSpeed)
  62. $("#customSpeed").on("click", () => {
  63. let input = prompt("自定义倍速(仅限正数)\n 存储在localStorage中,下次进入游戏自动读取\n暂停并取消后生效\n 非暂停状态修改倍数后脚本会自动暂停并取消\n 频繁修改倍速可能会导致游戏卡顿", customSpeed)
  64. if (isNaN(Number(input)) == false && Number(input) > 0) {
  65. customSpeed = input * 1
  66. setValue("customSpeed", customSpeed)
  67. $("#customSpeed").text("自定义倍速x" + customSpeed)
  68. if (!vueMethod._data.s.pause) {
  69. fromScript = true
  70. vueMethod.pause()
  71. }
  72. } else {
  73. alert("输入有误,仅限正数")
  74. }
  75. })
  76. vueMethod = document.querySelector("#topBar").__vue__
  77. }
  78. }, 100)

QingJ © 2025

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