有没有办法将一些设置保存到本地计算机,而不是使用用户脚本的cookies?
如果设置不是全局的,则很难创建用于多个域的用户脚本。
来自评论:"I am using scriptish "。
发布于 2012-02-26 08:07:04
当然,这非常简单。Greasemonkey wiki记录了四种方法,允许您处理保存值,这些值可以是设置,也可以是您希望存储的任何其他内容:
您可能希望查看main API页面,了解其他有用的方法,而且还有一个完整的metadata block documentation页面。
唯一不起作用的方法是在Google Chrome内容脚本中。不过,有几种解决方案:您可以使用Google Chrome GM_*用户脚本,也可以通过在用户脚本(来自Devine.me)的开头包含以下内容来使GM_setValue和GM_getValue方法可用:
if (!this.GM_getValue || (this.GM_getValue.toString && this.GM_getValue.toString().indexOf("not supported")>-1)) {
this.GM_getValue=function (key,def) {
return localStorage[key] || def;
};
this.GM_setValue=function (key,value) {
return localStorage[key]=value;
};
this.GM_deleteValue=function (key) {
return delete localStorage[key];
};
}https://stackoverflow.com/questions/9447950
复制相似问题