Google Chrome Sync check if enabled via API/Extension?

后端 未结 6 2022
一个人的身影
一个人的身影 2021-01-01 13:14

Is it possible to programmatically check if Chrome Sync is configured in Google Chrome?

The reason I ask is that I am coding an Extension for Chrome that depends on

6条回答
  •  有刺的猬
    2021-01-01 14:20

    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 is not signed in to chrome.");
    }
    

    });

    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 P.S : I modified the code from below answered thread

提交回复
热议问题