Browse Source

Try not to show dupes in the extension list

Corey Prophitt 11 months ago
parent
commit
e635285a3b
1 changed files with 17 additions and 1 deletions
  1. 17 1
      extension/js/browser-action.js

+ 17 - 1
extension/js/browser-action.js

@@ -93,6 +93,15 @@ function saveCSV(data) {
   exportToCSV(filename, rows);
 }
 
+// Used to create a unique key out of an extension name for deduping.
+function key(str) {
+  if (!str) {
+    return "";
+  }
+
+  return str.replace(/\s/g, "").toLowerCase();
+}
+
 function decode(str) {
     if (!str) { return str; }
 
@@ -185,10 +194,13 @@ function showDataView(data) {
     return false;
   });
 
+  var added = {};
+
   data.Metadata.ext.sort(compare).forEach(function (e) {
     var li = document.createElement("li");
 
     if (e.path && e.path[0]) {
+
       // Append a link to the webstore description.
       var extensionId = e.path[0].split("/")[0];
 
@@ -203,7 +215,11 @@ function showDataView(data) {
       li.innerText = decode(e.name);
     }
 
-    document.querySelector("ul").appendChild(li);
+    if (!added[key(li.innerText)]) {
+      document.querySelector("ul").appendChild(li);
+    }
+
+    added[key(li.innerText)] = true;
   });
 
   document.querySelector(".extension-data").classList.remove("hidden");