Skip to content

Instantly share code, notes, and snippets.

@orenyomtov
Created October 2, 2018 19:28
Show Gist options
  • Save orenyomtov/9cc844604132189f755b4c3237e441f1 to your computer and use it in GitHub Desktop.
Save orenyomtov/9cc844604132189f755b4c3237e441f1 to your computer and use it in GitHub Desktop.
For educational purposes only
//Follow all the users in the current Medium page
function filterNodeListByAttribute(nodeList, attributeName) {
let foundAttributeValues = []
return Array.prototype.slice.call(nodeList).filter(function(node) {
let attributeValue = node.getAttribute(attributeName)
return foundAttributeValues.indexOf(attributeValue) == -1 && foundAttributeValues.push(attributeValue)
})
}
filterNodeListByAttribute(document.querySelectorAll('*[data-action="toggle-subscribe-user"]:not(.is-active)'), 'data-action-value').forEach(subscribeButton => subscribeButton.click())
//Unfollow all the users in the current Medium page
function filterNodeListByAttribute(nodeList, attributeName) {
let foundAttributeValues = []
return Array.prototype.slice.call(nodeList).filter(function(node) {
let attributeValue = node.getAttribute(attributeName)
return foundAttributeValues.indexOf(attributeValue) == -1 && foundAttributeValues.push(attributeValue)
})
}
filterNodeListByAttribute(document.querySelectorAll('*[data-action="toggle-subscribe-user"].is-active'), 'data-action-value').forEach(subscribeButton => subscribeButton.click())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment