Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 脚本的执行顺序(@run-at)跟预期不符 #324

Open
CrayonSSR opened this issue Nov 30, 2024 · 4 comments
Open

[BUG] 脚本的执行顺序(@run-at)跟预期不符 #324

CrayonSSR opened this issue Nov 30, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@CrayonSSR
Copy link

问题描述

@run-at统一设定为document-startdocument-end的脚本。

有的document-start会预期执行,有的执行却比设定document-end的还慢。

把脚本导出再导入到tampermonkey,反而不会出现执行顺序问题。

测试示例

测试环境

脚本文件

只设置@run-at,其余默认,内容统一为console.log('执行时期'),

scriptcat-backup-2024-12-01.zip

测试输出

预期执行
image

非预期执行
image

非预期执行
image

@CodFrm
Copy link
Member

CodFrm commented Dec 2, 2024

需要登录么?没有复现出来,试试打印一下url,看看是不是iframe呢?

@CrayonSSR
Copy link
Author

需要登录么?没有复现出来,试试打印一下url,看看是不是iframe呢?

没戏,这可能将成为一个未解之谜吧。

也许重构到MV3后问题就会消失,说不定是Chrome在有意无意的降低对MV2的兼容性。

测试

  • 网页中,并不存在任何iframe元素。
  • 我把代码大概改成下面格式。
!function(){
    console.log('run test document-start', location.href, window.self === window.top)
}();

显然,结果依旧

image

@CrayonSSR
Copy link
Author

Chrome已经在各种界面,开始要求你移除MV2的插件了。

它要是主动忽略一些对MV2的兼容,只要你还能勉强跑它就不会来给你修也很正常,毕竟再几个月就移除了。

image

@CodFrm
Copy link
Member

CodFrm commented Dec 5, 2024

MV3已经在重构了💔,等mv3重构后再看看还会不会有这个问题吧

@CodFrm CodFrm added this to the Manifest V3之后计划 milestone Dec 5, 2024
@CodFrm CodFrm added the bug Something isn't working label Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants