Created
June 10, 2018 20:26
-
-
Save chrislaughlin/d9a596456021b526c8967a32dd6383ce to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//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