我正在使用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 无法跨浏览器和设备同步的原因是什么?