Skip to content

Instantly share code, notes, and snippets.

@chrislaughlin
Created June 10, 2018 20:26
Show Gist options
  • Save chrislaughlin/d9a596456021b526c8967a32dd6383ce to your computer and use it in GitHub Desktop.
Save chrislaughlin/d9a596456021b526c8967a32dd6383ce to your computer and use it in GitHub Desktop.
//Click first close span
const possibleText = ['CLose', 'Dismiss', 'Close', 'I agree'];
const possibleTags = ['span', 'button', 'a'];
const findAndClick = tag => {
Array.from(
document.querySelectorAll(tag)
).find(item => {
let found = false;
possibleText.forEach(text => {
item.innerHTML.toLowerCase().includes(text.toLowerCase())
});
return found;
}).click()
}
possibleTags.forEach(findAndClick);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment