Is there an easy way to detect from the Chrome extension that the user has logged into their google account or not.
I think there is an unpleasant way to figure this out by loading the html / css / js resource which requires authentication. But I would like to do this in a "clear" way.
thanks and better Victor
some discussions were held on the chrome extension mailing list: http://groups.google.com/a/chromium.org/group/chromium-extensions/browse_thread/thread/6e46a3a6e46d9110/
, , Xml- Http google.com , :
: ( -)
var currentUser; var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function(data) { if (xhr.readyState == 4) { currentUser = null; if (xhr.status == 200) { var re = new RegExp(/<b class="?gb4"?>[\s]*([^<]+@[^<]+)<\/b>/i); var m = re.exec(xhr.responseText); if (m && m.length == 2) { currentUser = m[1]; } } console.log("Currently logged user (on google.com): " + currentUser); } }; xhr.open('GET', 'https://www.google.com/', false); xhr.send();
chrome.identity.getAuthToken({interactive: false}, function (token) { if (!token) { if (chrome.runtime.lastError.message.match(/not signed in/)) { console.log("not singed in"); } else { console.log("singed in"); } } });
"identity" .
"identity"
Source: https://habr.com/ru/post/1748462/More articles:Mime file type definition - mime-typesWord Automation - SaveAs - c ++How to get two \ multicolum in LaTeX table? - latexUnexplored files to commit without intermediate tracked file changes - gitEditing LaTeX with Emacs - finding unused \ ref - emacsVersion Number for Visual Studio 2008 SP1 (Professional) - visual-studio-2008Как я могу заставить Capistrano включать файлы .htaccess в развертывания? - rubyI want to create DDL for the whole schema in oracle 10 G? - oraclewhen using window.print () for background colors for table cells not printing - javascriptAre protocols inherited in Objective-C? - objective-cAll Articles