Created
August 21, 2017 09:03
-
-
Save JarvisPrestidge/3929417fe63f878bac6392b05915fa0f to your computer and use it in GitHub Desktop.
Account link from 'displayName'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Returns the href of the account with the given account title | |
const accountLink = await browser.evaluate((displayName: string) => { | |
const accountTitleSelector = "a[id*='lnkAccName_des-m-sat-xx-']"; | |
const titles = [...document.querySelectorAll(accountTitleSelector)] as HTMLAnchorElement[]; | |
const title = titles.filter((ele) => ele.textContent.toLowerCase().includes(displayName.toLowerCase()))[0]; | |
return title ? title.getAttribute("href") : null; | |
}, account.displayName) as string; | |
// Get account href from camel-cased display name | |
if (!accountLink) { | |
throw new Error("Cannot find matching account title"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment