Use document.evaluate, for example:
document.evaluate('//td[contains(@class, "owner")]//div[@class="user-details"]/a', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue.innerHTML
If you run it on this page, it will show your username. Running it on some other page, that does not have similar element, would show error:
TypeError: document.evaluate(...).singleNodeValue is null
More generically, document.evaluate
returns an object of type XPathResult, which can be used to retrieved various aspects of evaluated XPath. You can also customize result type (4th argument).