From b426e6f8e38ce84980ca040b945fd98e191bb233 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 28 May 2012 15:00:56 +0200 Subject: [PATCH] Tweak [code] syntax highlighting, only execute it on inserted posts, not on page init. --- 4chan_x.user.js | 2 +- script.coffee | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index ff8f74507..3419b9f5a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -4070,7 +4070,6 @@ }); } } - Main.hasCodeTags = !!$('script[src="//static.4chan.org/js/prettify/prettify.js"]'); board = $('.board'); nodes = []; _ref1 = $$('.postContainer', board); @@ -4079,6 +4078,7 @@ nodes.push(Main.preParse(node)); } Main.node(nodes, true); + Main.hasCodeTags = !!$('script[src="//static.4chan.org/js/prettify/prettify.js"]'); if (MutationObserver = window.WebKitMutationObserver || window.MozMutationObserver || window.OMutationObserver || window.MutationObserver) { observer = new MutationObserver(Main.observer); return observer.observe(board, { diff --git a/script.coffee b/script.coffee index 3e7e135c0..45ba65eb2 100644 --- a/script.coffee +++ b/script.coffee @@ -3099,14 +3099,15 @@ Main = if Conf['Index Navigation'] setTimeout -> Nav.init() - Main.hasCodeTags = !! $ 'script[src="//static.4chan.org/js/prettify/prettify.js"]' - board = $ '.board' nodes = [] for node in $$ '.postContainer', board nodes.push Main.preParse node Main.node nodes, true + # Execute these scripts on inserted posts, not page init. + Main.hasCodeTags = !! $ 'script[src="//static.4chan.org/js/prettify/prettify.js"]' + if MutationObserver = window.WebKitMutationObserver or window.MozMutationObserver or window.OMutationObserver or window.MutationObserver observer = new MutationObserver Main.observer observer.observe board,