From 03819cec0a4d2f1efa25e21191900625564a3fce Mon Sep 17 00:00:00 2001 From: Jason Barnabe Date: Fri, 27 Apr 2012 19:17:46 -0500 Subject: [PATCH] issue 24: Global and website styles show up twice --- storage.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/storage.js b/storage.js index 102d2935..5389cd36 100644 --- a/storage.js +++ b/storage.js @@ -82,7 +82,7 @@ function getStyles(options, callback) { } // now add in global ones getGlobalStyleIds(function(ids) { - style_ids = style_ids.concat(ids); + style_ids = uniqueArray(style_ids.concat(ids)); loadStyles(style_ids, options.enabled, options.url, callback); }); }); @@ -93,6 +93,12 @@ function getStyles(options, callback) { }, reportError); } +function uniqueArray(ar) { + return ar.filter(function(s, i, a){ + return i === a.lastIndexOf(s); + }); +} + function getCache(callback) { if (isBackground()) { callback(cachedStyles);