Skip to content

Instantly share code, notes, and snippets.

@camilojd
Created May 27, 2018 18:00
Show Gist options
  • Save camilojd/511f6ce13b35270fae2591c80c71dd3d to your computer and use it in GitHub Desktop.
Save camilojd/511f6ce13b35270fae2591c80c71dd3d to your computer and use it in GitHub Desktop.
Show twitter poll results
function obtainPollIframes() {
return Array.prototype.slice.call(document.getElementsByTagName('iframe')).filter(function(fr) {
return fr.parentElement.className.indexOf('card-type-poll4choice') != -1
})
}
function modifyPollDescriptions(iframe) {
Array.prototype.slice.call(iframe.contentDocument.getElementsByClassName('PollXChoice-choice--text')).forEach(function(tuple) {
tuple.firstChild.nextSibling.textContent = tuple.firstChild.nextSibling.textContent + ' (' + tuple.firstChild.textContent + ')'
})
}
obtainPollIframes().forEach(function(poll) {
modifyPollDescriptions(poll)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment