user5508297 user5508297 - 3 months ago 8
Javascript Question

Google Chrome extension: How to find out if a user has signed in to the Chrome browser?

As part of a Google Chrome extension that I'm building I need to be able to tell if a user has signed in to the Google Chrome browser while the extension is enabled.

How can I do this?

Please note that using OAuth2 (and thus, the

API) is beyond the scope of my project so I need to find another way.

EDIT: my question is not a duplicate of this one because the solution in that thread no longer works.

Answer

Check if LSID cookie is set:

chrome.cookies.get({url:'https://accounts.google.com', name:'LSID'}, function(cookie) {
    if (cookie) {
        console.log('Sign-in cookie:', cookie);
    }
});

manifest.json permissions: "cookies", "https://accounts.google.com/"