Skip to content

Instantly share code, notes, and snippets.

@Maluen
Created April 21, 2017 18:50
Show Gist options
  • Save Maluen/c82581aaa488f73fdbe4d036e5e6f510 to your computer and use it in GitHub Desktop.
Save Maluen/c82581aaa488f73fdbe4d036e5e6f510 to your computer and use it in GitHub Desktop.
Extensions: simple heuristic way to check if the user is logged in (in any page)
export default function isPageLoggedIn() {
return Boolean(Array.from(document.body.querySelectorAll('a, button')).find(el => {
return el.innerText && el.innerText.match(/sign out|signout|log out|logout/i) !== null;
}));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment