using (loginLink = document.evaluate("//a[starts-with(@href, '/login/global') and text() = 'logged in' and not(ancestor::div[contains(@style,'display:none')]) and not(ancestor::div[contains(@style,'display: none')])]", document, null, 9 /*XPathResult.FIRST_ORDERED_NODE_TYPE*/, null).singleNodeValue)