Aileyu 发表于 2022-10-3 19:31:27

求助,油猴能实现在不同页面之间通信吗

我想在一个浏览器的不同页面之间相互传输数据,这个可以用油猴实现吗

steven026 发表于 2022-10-3 19:31:28

[油猴开发指南]关于脚本如何处理iframe的碎碎念
https://bbs.tampermonkey.net.cn/thread-2895-1-1.html
(出处: 油猴中文网)

可以参考这篇,不同域的iframe实际上算是2个页面了

Aileyu 发表于 2022-10-3 19:34:02

前提不用服务端服务器,好像shareworker可以实现不同页面通信,但油猴应该创建不了shareworker

李恒道 发表于 2022-10-3 20:05:01

GM_addValueChangeListener(name, function(name, old_value, new_value, remote) {})
Adds a change listener to the storage and returns the listener ID.
'name' is the name of the observed variable.
The 'remote' argument of the callback function shows whether this value was modified from the instance of another tab (true) or within this script instance (false).
Therefore this functionality can be used by scripts of different browser tabs to communicate with each other.
不知道符不符合你需求
页: [1]
查看完整版本: 求助,油猴能实现在不同页面之间通信吗