Chrome 同步不能跨浏览器和设备同步

wvmv3b1j  于 2023-01-28  发布在  Go
关注(0)|答案(3)|浏览(186)

我正在扩展中使用chrome.storage.sync来同步在popup.html的文本区域中输入的数据。
它可以在本地正确地存储和恢复数据,但不能跨浏览器同步数据。
每个浏览器扩展都有自己的本地输入数据可用。
下面的代码用于保存和恢复数据:

// Called when the user opens popup.html
$(window).ready(
    function restore() {
        var textarea = document.querySelector("#contacts");
        chrome.storage.sync.get('contacts', function(r) {
            console.log("Contacts retrieved");
            var content = r["contacts"];
            textarea.value = content;
        });
});

// Called when user saves his changes to the textarea
$("#save-button").click(function() {
        var textarea = document.querySelector("#contacts").value;
        var save = {};
        save["contacts"] = textarea;
        // Save data using the Chrome extension storage API.
        chrome.storage.sync.set(save, function() {
            console.log("Contacts saved");
        });
        $("#confirm").text("Contacts saved.").show().fadeOut(5000);
});

在我的manifest.json中,我向storage授予权限:

"permissions": [
        "tabs", 
        "http://*/*", 
        "storage"
    ]
}

Chrome Sync无法跨浏览器和设备同步的原因是什么?

xzlaal3s

xzlaal3s1#

您的扩展程序是否上传到Chrome网上商店账户并发布(或至少发布给测试人员)?
上次我检查的时候,跨计算机同步在非网络商店扩展上不起作用,所以你必须把它放在Chrome网络商店上测试。
您还必须确保在chrome://settings/syncSetup下选中Extensions

n3ipq98p

n3ipq98p2#

Google Storage API似乎有一些限制,比如每分钟的同步次数和要同步的项目的重量。我发现了这个:http://www.developer.com/lang/synchronized-storage-between-multiple-computers-with-chrome-sync.html
我希望这会有所帮助;)

exdqitrt

exdqitrt3#

Credit to "方 觉" who commented on Aug 2, 2013 at 6:01.
进入chrome://sync,你可以看到正在同步的扩展列表以及同步时间。

相关问题