scriptscat / scriptcat

脚本猫,一个可以执行用户脚本的浏览器扩展
https://docs.scriptcat.org
GNU General Public License v3.0
1.38k stars 128 forks source link

控制台报错MutationEvent is not defined #299

Closed MerielVaren closed 2 months ago

MerielVaren commented 2 months ago

脚本地址:更好的 Youtube Shorts

  1. 运行环境为:Chrome Dev 128.0.6559.0

    • 暴力猴 2.20.0:正常运行
    • 脚本猫 0.16.3:控制台报错 MutationEvent is not defined
  2. 运行环境为:Chrome 126.0.6478.127

    • 暴力猴 2.20.0:正常运行
    • 脚本猫 0.16.3:正常运行

MutationEvent从127开始被移除,但是我并没有使用MutationEvent,我在脚本中只使用了MutationObserver,而MutationObserver并没有被弃用

已知可以在用户端把chrome://flags/#mutation-events设置为Enabled解决这个问题,脚本猫是否可以像https://github.com/Tampermonkey/tampermonkey/issues/2011#issuecomment-2022872478一样在之后的版本中修复这个问题

CodFrm commented 2 months ago

81e33ced68c2bc0f163e1a99fe1e6b95

啊,这个东西还挺重要的,影响有点严重了,我研究一下

https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent

主要是在脚本猫中的消息交互有用到

CodFrm commented 2 months ago

请问什么时候会触发?

我使用128.0.6559.0(正式版本)dev (arm64),脚本猫 v0.16.4,运行上述脚本,暂未复现

MerielVaren commented 2 months ago

浏览器:Chrome Dev 128.0.6559.0 网址:https://www.youtube.com/shorts/8Og5ZESMi8s 脚本猫版本:0.16.4 (github release) / 0.16.3 (chrome网上应用商店) 插件地址:https://greasyfork.org/zh-CN/scripts/487271-better-youtube-shorts 报错信息:MutationEvent is not defined

以上运行环境下稳定触发上述的报错 @CodFrm

MerielVaren commented 2 months ago

当我在相同的运行环境下使用另一个用到MutationObserver的插件去除链接重定向访问bing - hello时,Chrome Dev给出了更多的报错信息

content.ts在通信时用到了MutationEvent,有没有可能换成CustomEvent等其他方法来绕过MutationEvnet?

希望对作者有所帮助 屏幕截图 2024-07-11 161540

MerielVaren commented 2 months ago

81e33ced68c2bc0f163e1a99fe1e6b95

啊,这个东西还挺重要的,影响有点严重了,我研究一下

https://developer.mozilla.org/en-US/docs/Web/API/MutationEvent

主要是在脚本猫中的消息交互有用到

是的,我认为这个bug需要及时得到修复,因为根据时间表来看,Chrome稳定版将在7月23日升到v127,如果不修复的话彼时可能所有带有MutationObserver或MutationEvent的插件将不能正常工作

CodFrm commented 2 months ago

修复了,哥哥试试这个版本:https://github.com/scriptscat/scriptcat/actions/runs/9901910434

主要影响到使用了GM_addElement/addStyle的脚本

没问题的话,我会尽快发布这个版本

MerielVaren commented 2 months ago

我这边测了一下没有报错了