Skip to content

Instantly share code, notes, and snippets.

@wovalle
Created March 27, 2019 14:57
Show Gist options
  • Save wovalle/599e2ff6509f909893f4972b1e332947 to your computer and use it in GitHub Desktop.
Save wovalle/599e2ff6509f909893f4972b1e332947 to your computer and use it in GitHub Desktop.
Only works in an instagram post page. Takes the text you have in the comment input and post each line as a comment every 2s
const frm = document.querySelector('article form')
const commentBox = frm.querySelector('textarea')
const postButton = frm.querySelector('button')
const comments = commentBox.value.split('\n').filter(c => c.length)
const postComment = comment => {
console.log('Commenting: ', comment)
let lastValue = commentBox.value
commentBox.value = comment
let event = new Event('input', { bubbles: true })
let tracker = commentBox._valueTracker
if (tracker)
tracker.setValue(lastValue)
}
commentBox.dispatchEvent(event)
postButton.click()
}
comments.forEach((comment, i) => {
setTimeout(() => postComment(comment) , i * 2000)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment