Skip to content

Instantly share code, notes, and snippets.

@jazzyjackson
Created July 23, 2017 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jazzyjackson/1348aa0b06b5cba800873b3fde0ff5a1 to your computer and use it in GitHub Desktop.
Save jazzyjackson/1348aa0b06b5cba800873b3fde0ff5a1 to your computer and use it in GitHub Desktop.
makeStrongTagsClickable(){
/**** Get the set of strong tags that chatbot returned, create a function
* with a reference to those particular strong tags, put a reference
* to that function in an event listener. destroy strong tags when you click one. ****/
var strongTags = this.body.querySelectorAll('strong')
var destroyStrongTags = () => Array.from(strongTags, strongTag => {
var spanFromStrong = document.createElement('span')
spanFromStrong.textContent = strongTag.textContent
strongTag.parentElement.replaceChild(spanFromStrong, strongTag)
})
Array.from(strongTags, strongTag => {
strongTag.addEventListener('click', () => {
autoSubmit(strongTag.textContent, {headless: false})
destroyStrongTags()
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment