0

我在 mozilla firefox 中使用greasemonkey 运行两个脚本。这些脚本在不同的网站上运行。在第一个脚本中,我想将一个变量“全局”保存到 firefox 中,这样我就可以在另一个网站的第二个脚本中使用它。

button.onclick = function() {myFunction()};

function myFunction() {
  //localStorage.setItem('savedvariable', document.URL)
  //window.name = document.URL;
  //sessionStorage.setItem('savedvariable', document.URL)
  //document.cookie = "savedvariable=" + document.URL;
}

我试过的所有选项都不起作用,所以寻找解决方法。

在第二个脚本中,我希望为第一个脚本中保存的变量设置一个文本框值:

var TextBox = document.getElementById("downloadUrlLabel");
TextBox.value = "placeholder variable";

有没有办法让这样的事情发生(将变量全局保存到firefox中),而不会使它变得复杂?

PS:抱歉,如果之前已经回答过,尝试寻找但找不到

4

0 回答 0