如何知道是否使用javascript启用了Chrome浏览器中的打开同步 [英] How to know whether turn on sync in chrome browser is enabled using javascript
问题描述
我正在尝试以编程方式检查以下要点1.检查是否在Chrome浏览器中启用了打开同步
到目前为止,我已经开发了chrome扩展,并尝试获取chrome.storage.sync对象但是我无法获得是否已同步"打开同步的状态
下面是我的manifest.json{"name":检查打开同步","version":"1.0","description":构建扩展!",权限":[存储"],背景": {"scripts":["background.js"],持续":假},"manifest_version":2}
我提供了一个background.js文件
chrome.storage.sync中有一种方法可以提供同步状态
我将回答自己的问题,因为我能够找到答案.
我能够获得同步状态为打开或否以及电子邮件ID.这是代码:
使用以下内容创建manifest.json文件
{"name":测试开启同步","version":"1.0","description":扩展名",权限":[身份","identity.email"],背景": {"scripts":["background.js"],持续":假},"manifest_version":2}
在同一文件夹中创建background.js文件
chrome.identity.getProfileUserInfo(function(data){如果(data.id){警报(数据);}别的{alert(用户尚未打开同步");}});
将文件夹添加为chrome扩展名在identity.email的帮助下从chrome运行扩展名,您可以获取打开了同步功能的用户的电子邮件ID以及状态信息.>
I am trying to check below point for my assignment programatically 1. check if turn on sync is enabled in chrome
EDIT: So far i have developed a chrome extension and trying to get the chrome.storage.sync object But i am unable to get the status of the turn on sync "whether synced or no"
Below is my manifest.json
{
"name": "Check Turn on sync",
"version": "1.0",
"description": "Build an Extension!",
"permissions": ["storage"],
"background": {
"scripts": ["background.js"],
"persistent": false
},
"manifest_version": 2
}
I have provided a background.js file
is there a way in chrome.storage.sync that provides status of the sync
I am going to answer my own question, as i was able to find the answer.
I was able to get the status of sync is turned on or no along with the email ids. Here is the code :
create a manifest.json file with below content
{
"name": "Test turn on sync",
"version": "1.0",
"description": "Extension",
"permissions":[
"identity",
"identity.email"
],
"background": {
"scripts": ["background.js"],
"persistent": false
},
"manifest_version": 2
}
Create a background.js file in the same folder
chrome.identity.getProfileUserInfo(function(data) {
if (data.id) {
alert(data);
}
else
{
alert("User has not turned on sync");
}
});
Add the folder as chrome extension Run the extension from chrome with the help of identity.email in permissions, you will be able to get even the email-id of the user who has turned on sync, along with status.
这篇关于如何知道是否使用javascript启用了Chrome浏览器中的打开同步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!