Skip to content

Commit 90897df

Browse files
committed
Initialize mute shortcut
1 parent 10ffd43 commit 90897df

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

chrome/src/inject/inject.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// Retriving user options
22
chrome.extension.sendMessage({}, function (settings) {
33
initOnHashChangeAction(settings['Domains'])
4-
initShortcuts(settings['Shortcut'], settings['BackgroundShortcut'])
4+
initShortcuts(settings['Shortcut'], settings['BackgroundShortcut'], settings['MuteShortcut'])
5+
56
initListViewShortcut()
67
initForInbox()
78
})
@@ -51,9 +52,10 @@ function initOnHashChangeAction(domains) {
5152
url = github_links[github_links.length-2].href
5253
muteLink = document.createElement('button')
5354
muteLink.type = 'button'
54-
muteLink.className = 'ithub-mute-button T-I J-J5-Ji lS T-I-ax7 ar7'
55+
muteLink.className = 'github-mute-button T-I J-J5-Ji lS T-I-ax7 ar7'
5556
muteLink.innerText = 'Mute thread'
5657
muteLink.addEventListener('click', function () {
58+
muteLink.innerHTML = '⋯'
5759
fetch(muteURL, {mode: 'no-cors'}).then(function () {
5860
muteLink.innerText = 'Muted!'
5961
muteLink.disabled = 'disabled'
@@ -93,7 +95,7 @@ function initOnHashChangeAction(domains) {
9395
}
9496
}
9597

96-
function initShortcuts(shortcut, backgroundShortcut) {
98+
function initShortcuts(shortcut, backgroundShortcut, muteShortcut) {
9799
document.addEventListener('keydown', function (event) {
98100
// Shortcut: bind user's combination, if a button exist and event not in a textarea
99101
if (document.querySelector('.gE')) {
@@ -112,6 +114,11 @@ function initShortcuts(shortcut, backgroundShortcut) {
112114
if (processRightCombinationBasedOnShortcut(backgroundShortcut, event) && window.idled && getVisible(document.getElementsByClassName('github-link')) && notAnInput(event.target)) {
113115
triggerGitHubLink(true)
114116
}
117+
118+
// Mute Shortcut: bind user's combination, if a button exist and event not in a textarea
119+
if (processRightCombinationBasedOnShortcut(muteShortcut, event) && window.idled && getVisible(document.getElementsByClassName('github-mute-button')) && notAnInput(event.target)) {
120+
getVisible(document.getElementsByClassName('github-mute-button')).click()
121+
}
115122
})
116123
}
117124

0 commit comments

Comments
 (0)