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

[Feature Request] 后台函数 #270

Open
WOSHIZHAZHA120 opened this issue Apr 28, 2024 · 2 comments
Open

[Feature Request] 后台函数 #270

WOSHIZHAZHA120 opened this issue Apr 28, 2024 · 2 comments

Comments

@WOSHIZHAZHA120
Copy link

场景

需要继续在后台执行一段函数, 如 自动刷题, 自动看课

替代

显示一个大黑框提示用户不要关闭浏览器

建议

提供类似于 Cat_runInBackground(name: string, fn: () => unknown): BackgroundFunctionInfo 的方法
相同 name 时如果已运行则可以获取到一些运行的信息

其实还想获取一些额外信息, 比如尝试的次数, 日志等 但这样就完全想不到如何设计一个好的 Api 了 🤔

@CodFrm
Copy link
Member

CodFrm commented Apr 28, 2024

fn无法传出去,没办法执行,这做不到

可以考虑使用通信的方式来实现,后台脚本一直运行,然后使用GM_addValueChangeListener来监听值变化

后续可以考虑出专门通信的函数

@CodFrm
Copy link
Member

CodFrm commented Jul 9, 2024

哥哥目前可以参考这个,使用通信的方式去处理

[脚本猫开发]油猴脚本与后台脚本交互
https://bbs.tampermonkey.net.cn/thread-925-1-1.html
(出处: 油猴中文网)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants