BLTH icon indicating copy to clipboard operation
BLTH copied to clipboard

[bug] 没有控制面板

Open unprintable123 opened this issue 3 years ago • 12 comments

描述bug

没有控制面板。但是暴力加上一个settimeout后修好了(),猜测是加载太早,可以等dom加载完了再跑。

重现bug

。

预期行为

出现控制面板。

截图

No response

运行日志

。

操作系统

win10

浏览器

chrome 115.0.5790.110

用户脚本管理器

4.19.0

脚本版本号

7.0.2

网络情况

一般

其他浏览器拓展/用户脚本

No response

其他

No response

unprintable123 avatar Jul 29 '23 13:07 unprintable123

有没有控制台日志?你是指document.body这个DOM节点没加载好吗。

https://github.com/andywang425/BLTH/blob/d3aa96e20ab7dc3e0815a4417d1d19f538c7302f/src/main.ts#L37-L40

andywang425 avatar Jul 29 '23 14:07 andywang425

控制台啥也没有,甚至没报错。应该是吧

unprintable123 avatar Jul 30 '23 08:07 unprintable123

去看了下,是isTargetFrame的_unsafeWindow.BilibiliLive还没定义,直接不跑了

unprintable123 avatar Jul 30 '23 08:07 unprintable123

😂我新版本也有这个问题,我还以为是跟防广告之类插件的冲突

OreoProMax avatar Jul 30 '23 10:07 OreoProMax

去看了下,是isTargetFrame的_unsafeWindow.BilibiliLive还没定义,直接不跑了

能不能帮忙测试一下,你那边脚本最早可以运行的时机是什么?根据文档改一下脚本头部的@run_at,去掉你加的setTimeout。

https://www.tampermonkey.net/documentation.php#meta:run_at

@run-at Defines the moment the script is injected. In opposition to other script handlers, @run-at defines the first possible moment a script wants to run. This means it may happen, that a script that uses the @require tag may be executed after the document is already loaded, cause fetching the required script took that long. Anyhow, all DOMNodeInserted and DOMContentLoaded events that happended after the given injection moment are cached and delivered to the script when it is injected.

// @run-at document-start The script will be injected as fast as possible.

// @run-at document-body The script will be injected if the body element exists.

// @run-at document-end The script will be injected when or after the DOMContentLoaded event was dispatched.

// @run-at document-idle The script will be injected after the DOMContentLoaded event was dispatched. This is the default value if no @run-at tag is given.

andywang425 avatar Jul 30 '23 11:07 andywang425

document-body是没问题的

unprintable123 avatar Jul 30 '23 13:07 unprintable123

document-body是没问题的

谢谢。

andywang425 avatar Jul 30 '23 13:07 andywang425

刚发现暴力猴不支持document-body( https://violentmonkey.github.io/api/metadata-block/#run-at ),那只能再延后到document-end。但这就意味着拦截直播流等需要劫持ajax请求的功能可能就没法做了。

andywang425 avatar Jul 30 '23 13:07 andywang425

隐身入场还是很好用的。。。BilibiliLive的定义是写在head里面的。也许可以直接监听事件(或者用MutationObserver)?甚至可以拿setter监听。

unprintable123 avatar Jul 30 '23 14:07 unprintable123

或者先把ajax拦截了再用事件监听等body加载完?

unprintable123 avatar Jul 30 '23 14:07 unprintable123

我再想想吧。不过我还是很好奇为什么你那边在document-start的时候运行就会出问题,我的运行环境和你的一模一样。有时候油猴脚本真挺玄学的,一样的环境不一样的结果。

andywang425 avatar Jul 30 '23 15:07 andywang425

新版我也没控制面板的,用的谷歌浏览器,不过旧版还可以所以还在用旧版

SameIe avatar Jul 30 '23 18:07 SameIe