Skip to content

Instantly share code, notes, and snippets.

@JustinShenk
Last active May 13, 2019 17:25
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 JustinShenk/f5c748cb9bc02de5cf8d26d88b67a039 to your computer and use it in GitHub Desktop.
Save JustinShenk/f5c748cb9bc02de5cf8d26d88b67a039 to your computer and use it in GitHub Desktop.
Agreed - Chrome Extension for agreeing with reactions on Slack
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
`
})
}
});
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()
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