Last active
May 13, 2019 17:25
-
-
Save JustinShenk/f5c748cb9bc02de5cf8d26d88b67a039 to your computer and use it in GitHub Desktop.
Agreed - Chrome Extension for agreeing with reactions on Slack
This file contains 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
chrome.commands.onCommand.addListener(function(command) { | |
if (command === "agree-first-reaction") { | |
chrome.tabs.executeScript({ | |
code: ` ... // code from clickFirstReaction.js | |
` | |
}) | |
} else if (command === "agree-every-reaction") { | |
chrome.tabs.executeScript({ | |
code: ` ... // code form clickEveryReaction.js | |
` | |
}) | |
} | |
}); |
This file contains 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
function clickEveryReaction() { | |
const query = "div > button.c-reaction:not(.c-reaction--reacted)"; | |
const reactionsToClick = document.querySelectorAll(query); | |
const beforeCount = reactionsToClick.length; | |
if (reactionsToClick.length) { | |
reactionsToClick.forEach((button) => { button.click()} ); | |
} | |
const afterCount = document.querySelectorAll(query).length; | |
} | |
clickEveryReaction() |
This file contains 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
function clickFirstReaction() { | |
const query = "div.c-reaction_bar > button:nth-child(1):not(.c-reaction--reacted)"; | |
const reactionsToClick = document.querySelectorAll(query); | |
const beforeCount = reactionsToClick.length; | |
if (reactionsToClick.length) { | |
reactionsToClick.forEach((button) => { button.click()} ); | |
} | |
const afterCount = document.querySelectorAll(query).length; | |
} | |
clickFirstReaction() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment