在2个单独的脚本之间共享变量 [英] Sharing variables between 2 separate scripts

查看:200
本文介绍了在2个单独的脚本之间共享变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在2个单独的标签中运行的2个不同的Tampermonkey脚本之间共享变量.

I'm trying to share variable between 2 different Tampermonkey scripts running in 2 separate tabs.

我尝试在一个脚本中使用GM_setValue,然后在另一个脚本中使用GM_getValue检索它,但没有成功,因此我假设每个脚本都有单独的存储.

I tried using GM_setValue in one script then retrieving it with GM_getValue in the other one but without any success, so I assume there's separate storage for each script.

有没有简单的方法可以做到这一点?我只是想念一些简单的东西吗?我能以某种方式使两个脚本共享相同的存储空间吗?

Is there any easy way to do this? Am I just missing something simple? Can I somehow make both scripts share the same storage?

推荐答案

是的,可以.您可以使用 localStorage ,也可以在服务器上使用数据库并获取/设置 AJAX 的值.

Yes, you can. You can use localStorage, or you can use a database at your server and get/set values with AJAX.

这篇关于在2个单独的脚本之间共享变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆