Implement Count Posts by ID. #851

This commit is contained in:
ccd0 2016-06-19 02:24:02 -07:00
parent 160bf025c8
commit 1ff286ad3a
3 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,22 @@
IDPostCount =
init: ->
return unless g.VIEW is 'thread' and Conf['Count Posts by ID']
Callbacks.Thread.push
name: 'Count Posts by ID'
cb: -> IDPostCount.thread = @
Callbacks.Post.push
name: 'Count Posts by ID'
cb: @node
node: ->
if @nodes.uniqueID and @thread is IDPostCount.thread
$.on $('span.hand', @nodes.uniqueID), 'mouseover', IDPostCount.count
count: ->
{uniqueID} = Get.postFromNode(@).info
n = 0
IDPostCount.thread.posts.forEach (post) ->
n++ if post.info.uniqueID is uniqueID
@title = "#{n} post#{if n is 1 then '' else 's'} by this ID"
return IDPostCount

View File

@ -97,6 +97,10 @@ Config =
true
'Assign unique colors to user IDs on boards that use them'
]
'Count Posts by ID': [
true
'Display number of posts in the thread when hovering over an ID.'
]
'Remove Spoilers': [
false
'Remove all spoilers in text.'

View File

@ -438,6 +438,7 @@ Main =
['Fourchan thingies', Fourchan]
['Color User IDs', IDColor]
['Highlight by User ID', IDHighlight]
['Count Posts by ID', IDPostCount]
['Custom CSS', CustomCSS]
['Thread Links', ThreadLinks]
['Linkify', Linkify]