From 700455ba9973fa4323eb6ef15fe9bf1e7c389f4a Mon Sep 17 00:00:00 2001 From: Adam Hughes Date: Mon, 22 Mar 2010 17:40:26 -0400 Subject: [PATCH] add original poster css once in bulk instead of once per root post. --- chromeshack_posts.js | 1 + init_events.js | 1 + scripts/highlight_original_poster.js | 21 +++++++++++++++++---- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/chromeshack_posts.js b/chromeshack_posts.js index 2e59e02f..3c43147e 100644 --- a/chromeshack_posts.js +++ b/chromeshack_posts.js @@ -36,6 +36,7 @@ ChromeShack = { ChromeShack.processPost(item, item.id.substr(5)); } + fullPostsCompletedEvent.raise(); }, processPost: function(item, root_id) diff --git a/init_events.js b/init_events.js index 82d66c80..f9c9ec6a 100644 --- a/init_events.js +++ b/init_events.js @@ -17,5 +17,6 @@ Event.prototype.raise = function(arg1, arg2, arg3) } var processPostEvent = new Event(); +var fullPostsCompletedEvent = new Event(); var processPostBoxEvent = new Event(); var settingsLoadedEvent = new Event(); diff --git a/scripts/highlight_original_poster.js b/scripts/highlight_original_poster.js index 05e59393..24e4befc 100644 --- a/scripts/highlight_original_poster.js +++ b/scripts/highlight_original_poster.js @@ -8,7 +8,9 @@ settingsLoadedEvent.addHandler(function() css: getSetting("original_poster_css"), - highlight: function(item, id, is_root_post) + selectors: [], + + gatherCss: function(item, id, is_root_post) { if (is_root_post) { @@ -17,13 +19,24 @@ settingsLoadedEvent.addHandler(function() if (fpauthor) { var authorId = fpauthor[1]; - var style = "div#root_" + id + " div.olauthor_" + authorId + " a.oneline_user { " + HighlightOriginalPoster.css + " }"; - insertStyle(style); + HighlightOriginalPoster.selectors.push("div#root_" + id + " div.olauthor_" + authorId + " a.oneline_user "); } } + }, + + installCss: function() + { + if (HighlightOriginalPoster.selectors.length > 0) + { + var css = HighlightOriginalPoster.selectors.join(", "); + css += " { " + HighlightOriginalPoster.css + " }"; + insertStyle(css); + } } + } - processPostEvent.addHandler(HighlightOriginalPoster.highlight); + processPostEvent.addHandler(HighlightOriginalPoster.gatherCss); + fullPostsCompletedEvent.addHandler(HighlightOriginalPoster.installCss); } });