用于保存设置的脚本

Joh*_*ohn 4 greasemonkey scriptish

有没有办法将一些设置保存到本地计算机而不是带有用户脚本的cookie?

如果设置不是全局的,则很难为多个域创建用户脚本.

来自评论:"I am using scriptish ".

Ben*_*nRH 12

当然,这很容易.在Greasemonkey的维基文件的四种方法,让您处理保存价值,可以是你想存储的设置或其他任何东西:

您可能需要查看主API页面以获取其他有用的方法,还有一个完整的元数据块文档页面.

这可能不起作用的唯一方法是使用Google Chrome内容脚本.但是有一些解决方案:您可以使用Google Chrome GM_*用户脚本,也可以将GM_setValue和GM_getValue方法设置为用户脚本的开头(来自Devine.me):

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];
    };
}
Run Code Online (Sandbox Code Playgroud)

  • 我正在使用scriptish (3认同)