Fix ID highlighting.
This commit is contained in:
parent
bd7e01926b
commit
aaeff46c2b
@ -282,6 +282,7 @@ Main =
|
|||||||
['Announcement Hiding', PSAHiding]
|
['Announcement Hiding', PSAHiding]
|
||||||
['Fourchan thingies', Fourchan]
|
['Fourchan thingies', Fourchan]
|
||||||
['Color User IDs', IDColor]
|
['Color User IDs', IDColor]
|
||||||
|
['Highlight by User ID', IDHighlight]
|
||||||
['Custom CSS', CustomCSS]
|
['Custom CSS', CustomCSS]
|
||||||
['Linkify', Linkify]
|
['Linkify', Linkify]
|
||||||
['Reveal Spoilers', RemoveSpoilers]
|
['Reveal Spoilers', RemoveSpoilers]
|
||||||
|
|||||||
@ -40,9 +40,9 @@ class Clone extends Post
|
|||||||
if nodes.uniqueID
|
if nodes.uniqueID
|
||||||
@nodes.uniqueID = $ '.posteruid', info
|
@nodes.uniqueID = $ '.posteruid', info
|
||||||
if nodes.capcode
|
if nodes.capcode
|
||||||
@nodes.capcode = $ '.capcode', info
|
@nodes.capcode = $ '.capcode.hand', info
|
||||||
if nodes.flag
|
if nodes.flag
|
||||||
@nodes.flag = $ '.countryFlag', info
|
@nodes.flag = $ '.flag, .countryFlag', info
|
||||||
if nodes.date
|
if nodes.date
|
||||||
@nodes.date = $ '.dateTime', info
|
@nodes.date = $ '.dateTime', info
|
||||||
|
|
||||||
|
|||||||
@ -105,5 +105,3 @@ ExpandThread =
|
|||||||
|
|
||||||
postsCount = postsRoot.length
|
postsCount = postsRoot.length
|
||||||
a.textContent = ExpandThread.text '-', postsCount, filesCount
|
a.textContent = ExpandThread.text '-', postsCount, filesCount
|
||||||
|
|
||||||
Fourchan.parseThread thread.ID, 1, postsCount
|
|
||||||
|
|||||||
@ -2,8 +2,7 @@ Fourchan =
|
|||||||
init: ->
|
init: ->
|
||||||
return if g.VIEW is 'catalog'
|
return if g.VIEW is 'catalog'
|
||||||
|
|
||||||
board = g.BOARD.ID
|
if g.BOARD.ID is 'g'
|
||||||
if board is 'g'
|
|
||||||
$.globalEval '''
|
$.globalEval '''
|
||||||
window.addEventListener('prettyprint', function(e) {
|
window.addEventListener('prettyprint', function(e) {
|
||||||
window.dispatchEvent(new CustomEvent('prettyprint:cb', {
|
window.dispatchEvent(new CustomEvent('prettyprint:cb', {
|
||||||
@ -14,7 +13,8 @@ Fourchan =
|
|||||||
Post.callbacks.push
|
Post.callbacks.push
|
||||||
name: 'Parse /g/ code'
|
name: 'Parse /g/ code'
|
||||||
cb: @code
|
cb: @code
|
||||||
if board is 'sci'
|
|
||||||
|
if g.BOARD.ID is 'sci'
|
||||||
# https://github.com/MayhemYDG/4chan-x/issues/645#issuecomment-13704562
|
# https://github.com/MayhemYDG/4chan-x/issues/645#issuecomment-13704562
|
||||||
$.globalEval '''
|
$.globalEval '''
|
||||||
window.addEventListener('jsmath', function(e) {
|
window.addEventListener('jsmath', function(e) {
|
||||||
@ -35,6 +35,19 @@ Fourchan =
|
|||||||
CatalogThread.callbacks.push
|
CatalogThread.callbacks.push
|
||||||
name: 'Parse /sci/ math'
|
name: 'Parse /sci/ math'
|
||||||
cb: @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: ->
|
code: ->
|
||||||
return if @isClone
|
return if @isClone
|
||||||
apply = (e) ->
|
apply = (e) ->
|
||||||
@ -45,14 +58,8 @@ Fourchan =
|
|||||||
$.event 'prettyprint', pre.innerHTML, window
|
$.event 'prettyprint', pre.innerHTML, window
|
||||||
$.off window, 'prettyprint:cb', apply
|
$.off window, 'prettyprint:cb', apply
|
||||||
return
|
return
|
||||||
|
|
||||||
math: ->
|
math: ->
|
||||||
return if (@isClone and doc.contains @origin.nodes.root) or !$ '.math', @nodes.comment
|
return if (@isClone and doc.contains @origin.nodes.root) or !$ '.math', @nodes.comment
|
||||||
$.asap (=> doc.contains @nodes.comment), =>
|
$.asap (=> doc.contains @nodes.comment), =>
|
||||||
$.event 'jsmath', null, @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
|
else
|
||||||
Header.scrollTo root if root
|
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',
|
$.event 'ThreadUpdate',
|
||||||
404: false
|
404: false
|
||||||
threadID: ThreadUpdater.thread.fullID
|
threadID: ThreadUpdater.thread.fullID
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user