//just a quick function for copy/pasting into the console function xpath(path, root) { return document.evaluate(path, root || document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; } //more js-styled functions function getElementsByXPath(xpath, parent) { let results = []; let query = document.evaluate(xpath, parent || document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); for (let i = 0, length = query.snapshotLength; i < length; ++i) { results.push(query.snapshotItem(i)); } return results; } function getElementByXPath(path, root) { return document.evaluate(path, root || document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; } function shadowCss(query, target) { function findRoots(ele) { return [ele, ...ele.querySelectorAll('*')] .filter(e => !!e.shadowRoot) .flatMap(e => [e.shadowRoot, ...findRoots(e.shadowRoot)]) } return findRoots(target || document.body) .map(sr => sr.querySelector(query)) .filter(el => el != null)[0]; }