diff --git a/src/Miscellaneous/ExpandComment.coffee b/src/Miscellaneous/ExpandComment.coffee index 3e8da0ef9..6fbf847e0 100644 --- a/src/Miscellaneous/ExpandComment.coffee +++ b/src/Miscellaneous/ExpandComment.coffee @@ -2,9 +2,6 @@ ExpandComment = init: -> return if g.VIEW isnt 'index' or !Conf['Comment Expansion'] or Conf['JSON Index'] - @callbacks.push Fourchan.code if g.BOARD.ID is 'g' - @callbacks.push Fourchan.math if g.BOARD.ID is 'sci' - Callbacks.Post.push name: 'Comment Expansion' cb: @node diff --git a/src/Miscellaneous/Fourchan.coffee b/src/Miscellaneous/Fourchan.coffee index 581e0559e..7fba2af7f 100644 --- a/src/Miscellaneous/Fourchan.coffee +++ b/src/Miscellaneous/Fourchan.coffee @@ -1,8 +1,11 @@ Fourchan = init: -> - return unless g.VIEW in ['index', 'thread', 'archive'] + return unless Site.software is 'yotsuba' and g.VIEW in ['index', 'thread', 'archive'] + BoardConfig.ready @initBoard + Main.ready @initReady - if g.BOARD.ID is 'g' + initBoard: -> + if g.BOARD.config.code_tags $.on window, 'prettyprint:cb', (e) -> return if not (post = g.posts[e.detail.ID]) return if not (pre = $$('.prettyprint', post.nodes.comment)[e.detail.i]) @@ -21,10 +24,12 @@ Fourchan = }, false); ''' Callbacks.Post.push - name: 'Parse /g/ code' - cb: @code + name: 'Parse [code] tags' + cb: Fourchan.code + g.posts.forEach (post) -> Callbacks.Post.execute post, ['Parse [code] tags'], true + ExpandComment.callbacks.push Fourchan.code - if g.BOARD.ID is 'sci' + if g.BOARD.config.math_tags $.global -> window.addEventListener 'mathjax', (e) -> if window.MathJax @@ -40,16 +45,18 @@ Fourchan = , false , false Callbacks.Post.push - name: 'Parse /sci/ math' - cb: @math + name: 'Parse [math] tags' + cb: Fourchan.math + g.posts.forEach (post) -> Callbacks.Post.execute post, ['Parse [math] tags'], true + ExpandComment.callbacks.push Fourchan.math - # Disable 4chan's ID highlighting (replaced by IDHighlight) and reported post hiding. - Main.ready -> - $.global -> - window.clickable_ids = false - for node in document.querySelectorAll '.posteruid, .capcode' - node.removeEventListener 'click', window.idClick, false - return + # Disable 4chan's ID highlighting (replaced by IDHighlight) and reported post hiding. + initReady: -> + $.global -> + window.clickable_ids = false + for node in document.querySelectorAll '.posteruid, .capcode' + node.removeEventListener 'click', window.idClick, false + return code: -> return if @isClone diff --git a/src/classes/Callbacks.coffee b/src/classes/Callbacks.coffee index 797bd6129..f35629d9b 100644 --- a/src/classes/Callbacks.coffee +++ b/src/classes/Callbacks.coffee @@ -10,8 +10,8 @@ class Callbacks @keys.push name unless @[name] @[name] = cb - execute: (node, keys=@keys) -> - return if node.callbacksExecuted + execute: (node, keys=@keys, force) -> + return if node.callbacksExecuted and !force node.callbacksExecuted = true for name in keys try diff --git a/src/site/SW.tinyboard.coffee b/src/site/SW.tinyboard.coffee index 6e9f6fecc..307614a99 100644 --- a/src/site/SW.tinyboard.coffee +++ b/src/site/SW.tinyboard.coffee @@ -9,7 +9,6 @@ SW.tinyboard = 'Image Host Rewriting' 'Index Generator' 'Announcement Hiding' - 'Fourchan thingies' 'Resurrect Quotes' 'Quick Reply Personas' 'Quick Reply'