Fix ID highlighting.
This commit is contained in:
parent
bd7e01926b
commit
aaeff46c2b
@ -282,6 +282,7 @@ Main =
|
||||
['Announcement Hiding', PSAHiding]
|
||||
['Fourchan thingies', Fourchan]
|
||||
['Color User IDs', IDColor]
|
||||
['Highlight by User ID', IDHighlight]
|
||||
['Custom CSS', CustomCSS]
|
||||
['Linkify', Linkify]
|
||||
['Reveal Spoilers', RemoveSpoilers]
|
||||
|
||||
@ -40,9 +40,9 @@ class Clone extends Post
|
||||
if nodes.uniqueID
|
||||
@nodes.uniqueID = $ '.posteruid', info
|
||||
if nodes.capcode
|
||||
@nodes.capcode = $ '.capcode', info
|
||||
@nodes.capcode = $ '.capcode.hand', info
|
||||
if nodes.flag
|
||||
@nodes.flag = $ '.countryFlag', info
|
||||
@nodes.flag = $ '.flag, .countryFlag', info
|
||||
if nodes.date
|
||||
@nodes.date = $ '.dateTime', info
|
||||
|
||||
|
||||
@ -105,5 +105,3 @@ ExpandThread =
|
||||
|
||||
postsCount = postsRoot.length
|
||||
a.textContent = ExpandThread.text '-', postsCount, filesCount
|
||||
|
||||
Fourchan.parseThread thread.ID, 1, postsCount
|
||||
|
||||
@ -2,8 +2,7 @@ Fourchan =
|
||||
init: ->
|
||||
return if g.VIEW is 'catalog'
|
||||
|
||||
board = g.BOARD.ID
|
||||
if board is 'g'
|
||||
if g.BOARD.ID is 'g'
|
||||
$.globalEval '''
|
||||
window.addEventListener('prettyprint', function(e) {
|
||||
window.dispatchEvent(new CustomEvent('prettyprint:cb', {
|
||||
@ -14,7 +13,8 @@ Fourchan =
|
||||
Post.callbacks.push
|
||||
name: 'Parse /g/ code'
|
||||
cb: @code
|
||||
if board is 'sci'
|
||||
|
||||
if g.BOARD.ID is 'sci'
|
||||
# https://github.com/MayhemYDG/4chan-x/issues/645#issuecomment-13704562
|
||||
$.globalEval '''
|
||||
window.addEventListener('jsmath', function(e) {
|
||||
@ -35,6 +35,19 @@ Fourchan =
|
||||
CatalogThread.callbacks.push
|
||||
name: 'Parse /sci/ math'
|
||||
cb: @math
|
||||
|
||||
# Disable 4chan's ID highlighting (replaced by IDHighlight).
|
||||
$.ready ->
|
||||
$.globalEval '''
|
||||
(function() {
|
||||
clickable_ids = false;
|
||||
var nodes = document.querySelectorAll('.posteruid, .capcode');
|
||||
for (var i = 0; i < nodes.length; i++) {
|
||||
nodes[i].removeEventListener("click", idClick, false);
|
||||
}
|
||||
})();
|
||||
'''
|
||||
|
||||
code: ->
|
||||
return if @isClone
|
||||
apply = (e) ->
|
||||
@ -45,14 +58,8 @@ Fourchan =
|
||||
$.event 'prettyprint', pre.innerHTML, window
|
||||
$.off window, 'prettyprint:cb', apply
|
||||
return
|
||||
|
||||
math: ->
|
||||
return if (@isClone and doc.contains @origin.nodes.root) or !$ '.math', @nodes.comment
|
||||
$.asap (=> doc.contains @nodes.comment), =>
|
||||
$.event 'jsmath', null, @nodes.comment
|
||||
parseThread: (threadID, offset, limit) ->
|
||||
# Fix /sci/
|
||||
# Fix /g/
|
||||
$.event '4chanParsingDone',
|
||||
threadId: threadID
|
||||
offset: offset
|
||||
limit: limit
|
||||
|
||||
23
src/Miscellaneous/IDHighlight.coffee
Normal file
23
src/Miscellaneous/IDHighlight.coffee
Normal file
@ -0,0 +1,23 @@
|
||||
IDHighlight =
|
||||
init: ->
|
||||
return if g.VIEW is 'catalog'
|
||||
|
||||
Post.callbacks.push
|
||||
name: 'Highlight by User ID'
|
||||
cb: @node
|
||||
|
||||
uniqueID: null
|
||||
|
||||
node: ->
|
||||
$.on @nodes.uniqueID, 'click', IDHighlight.click @ if @nodes.uniqueID
|
||||
$.on @nodes.capcode, 'click', IDHighlight.click @ if @nodes.capcode
|
||||
IDHighlight.set @ unless @isClone
|
||||
|
||||
set: (post) ->
|
||||
match = (post.info.uniqueID or post.info.capcode) is IDHighlight.uniqueID
|
||||
$[if match then 'addClass' else 'rmClass'] post.nodes.post, 'highlight'
|
||||
|
||||
click: (post) -> ->
|
||||
uniqueID = post.info.uniqueID or post.info.capcode
|
||||
IDHighlight.uniqueID = if IDHighlight.uniqueID is uniqueID then null else uniqueID
|
||||
g.posts.forEach IDHighlight.set
|
||||
@ -333,12 +333,6 @@ ThreadUpdater =
|
||||
else
|
||||
Header.scrollTo root if root
|
||||
|
||||
$.queueTask ->
|
||||
# Enable 4chan features.
|
||||
threadID = ThreadUpdater.thread.ID
|
||||
{length} = $$ '.thread > .postContainer', ThreadUpdater.root
|
||||
Fourchan.parseThread threadID, length - count, length
|
||||
|
||||
$.event 'ThreadUpdate',
|
||||
404: false
|
||||
threadID: ThreadUpdater.thread.fullID
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user