【问题标题】:Firefox Addon: Get Sync Device NameFirefox 插件:获取同步设备名称
【发布时间】:2015-03-01 20:00:55
【问题描述】:

我正在为 Firefox 编写一个简单的插件。

用户可以选择在Firefox Sync中设置设备名称

如何在插件代码中获取名称“我的电脑”?

这是一个非常简单的扩展

ma​​in.js

var buttons = require('sdk/ui/button/action');
var tabs = require("sdk/tabs");

var deviceName = what.what?

【问题讨论】:

    标签: firefox-addon firefox-addon-sdk


    【解决方案1】:

    可能使用编织服务,但我无法弄清楚:

    var WeaveService = Cc["@mozilla.org/weave/service;1"].getService(Ci.nsISupports);
        // Referencing Weave.Service will implicitly initialize sync, and we don't
        // want to force that - so first check if it is ready.
    /* WeaveService object holds these:
    enabled:true
    fxAccountsEnabled:true
    ready:true
    */
    if (WaveService.ready) {
    
    }
    

    所以我作弊并阅读了pref值:

    var clientEngineName = Services.prefs.getCharPref('services.sync.client.name');
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多