tig-spy allow mute users
This commit is contained in:
@@ -23,8 +23,14 @@
|
|||||||
],
|
],
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"<all_urls>",
|
"<all_urls>",
|
||||||
"tabs"
|
"tabs",
|
||||||
|
"storage"
|
||||||
],
|
],
|
||||||
|
"browser_specific_settings": {
|
||||||
|
"gecko": {
|
||||||
|
"id": "{d6411b81-d2d8-439e-bf23-3c6856af71b8}"
|
||||||
|
}
|
||||||
|
},
|
||||||
"version": "0.0",
|
"version": "0.0",
|
||||||
"manifest_version": 2
|
"manifest_version": 2
|
||||||
}
|
}
|
@@ -30,7 +30,7 @@
|
|||||||
(for [idx post] (enumerate (postElements document))
|
(for [idx post] (enumerate (postElements document))
|
||||||
(let [links (post.getElementsByTagName "a")
|
(let [links (post.getElementsByTagName "a")
|
||||||
userLink (links.item (min idx 1))]
|
userLink (links.item (min idx 1))]
|
||||||
userLink.innerHTML)))))
|
userLink.href)))))
|
||||||
|
|
||||||
(function printPostStats [:Array<String> authors]
|
(function printPostStats [:Array<String> authors]
|
||||||
(let [:String subjectLine .innerHTML (document.getElementById "top_subject")
|
(let [:String subjectLine .innerHTML (document.getElementById "top_subject")
|
||||||
@@ -53,6 +53,47 @@
|
|||||||
(print "$updates updates by OP")
|
(print "$updates updates by OP")
|
||||||
(print "$replies replies by $(count repliers) followers")))
|
(print "$replies replies by $(count repliers) followers")))
|
||||||
|
|
||||||
|
// Mute losers:
|
||||||
|
(window.addEventListener "load"
|
||||||
|
->:Void
|
||||||
|
(awaitLet [mutedIds (API.browser.storage.sync.get (object mutedIds []))
|
||||||
|
&sync posts (postElements document)]
|
||||||
|
(doFor [idx post] (enumerate posts)
|
||||||
|
(let [links (post.getElementsByTagName "a")
|
||||||
|
authorLink (links.item (min idx 1))
|
||||||
|
authorId authorLink.href
|
||||||
|
:Array<String> mutedIds (dictGet mutedIds "mutedIds")
|
||||||
|
isMuted (mutedIds.contains authorId)
|
||||||
|
authorName authorLink.innerHTML
|
||||||
|
muteLink (document.createElement "a")]
|
||||||
|
(set muteLink.innerHTML "$?(if isMuted "un")mute")
|
||||||
|
(muteLink.addEventListener "click"
|
||||||
|
(if isMuted
|
||||||
|
// unmute
|
||||||
|
->:Void {
|
||||||
|
(mutedIds.remove authorId)
|
||||||
|
(API.browser.storage.sync.set (objectWith mutedIds))
|
||||||
|
(set window.location.href window.location.href)
|
||||||
|
}
|
||||||
|
// mute
|
||||||
|
->:Void {
|
||||||
|
(mutedIds.push authorId)
|
||||||
|
(API.browser.storage.sync.set (objectWith mutedIds))
|
||||||
|
(set window.location.href window.location.href)
|
||||||
|
}))
|
||||||
|
(authorLink.parentElement.prepend (document.createElement "br"))
|
||||||
|
(authorLink.parentElement.prepend muteLink)
|
||||||
|
(when isMuted
|
||||||
|
(let [message "I am muted by tig-spy! :)"
|
||||||
|
[avatarElement] (post.getElementsByClassName "avatar")
|
||||||
|
:js.html.Element avatarParent avatarElement.parentElement
|
||||||
|
[postElement] (post.getElementsByClassName "post")
|
||||||
|
[signatureElement] (post.getElementsByClassName "signature")]
|
||||||
|
(avatarParent.removeChild avatarElement)
|
||||||
|
(set postElement.innerHTML message)
|
||||||
|
(set signatureElement.innerHTML message)))))))
|
||||||
|
|
||||||
|
// Link at the top of page 1 to run analytics:
|
||||||
(cond
|
(cond
|
||||||
((StringTools.endsWith window.location.href ".0")
|
((StringTools.endsWith window.location.href ".0")
|
||||||
(let [analyticsLink (document.createElement "a")]
|
(let [analyticsLink (document.createElement "a")]
|
||||||
|
Reference in New Issue
Block a user