Google Chrome Sync check if enabled via API/Extension?

后端 未结 6 2024
一个人的身影
一个人的身影 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 13:54

    Alternative way to find if service is synced or not:

    Get https://www.google.com/settings/chrome/sync?hl=en with language set to en, and then:

    var is_sync = 0;
    NodeList.prototype.forEach = Array.prototype.forEach;
    document.querySelectorAll(".Tda.CP").forEach(function(ele){
        if(ele.innerHTML == 'Omnibox History')
        is_sync = parseInt(ele.parentElement.querySelector('.FP.Uda').innerHTML);
    });
    

    Please note that you may want to verify last synchronization date, that is .zU.EP span, I got something like this:

    Last time synced on Wednesday, November 12, 2014 at 1:03:29 PM UTC+1

    This is the function I wrote to convert that to time:

    last_sync = new Date(document.querySelector('.zU.EP').innerHTML.replace('Last time synced on ','').match(/.*\sat/)[0].replace(' at','')).getTime();
    

    Maybe not the best, but works, and gives an idea.

提交回复
热议问题