]> spindle.queued.net Git - midori/commitdiff
Use id to avoid inserting adblock/ form history style more than once
authorAlexander Butenko <a.butenka@gmail.com>
Wed, 23 Dec 2009 14:35:09 +0000 (15:35 +0100)
committerChristian Dywan <christian@twotoasts.de>
Wed, 23 Dec 2009 14:35:09 +0000 (15:35 +0100)
extensions/adblock.c
extensions/formhistory.c

index f1c36c25130c0661fd668eff58d6f1e8648b789c..cb5162d19ef7dd8eb43124732793cf5bdd22f0b1 100644 (file)
@@ -44,11 +44,8 @@ adblock_build_js (const gchar* style,
     return g_strdup_printf (
         "window.addEventListener ('DOMContentLoaded',"
         "function () {"
-        "   var styles = document.getElementsByTagName('style');"
-        "   for (i=0; i<styles.length; i++) {"
-        "       if (styles[i].getAttribute('title') == 'madblock')"
-        "           return;"
-        "   }"
+        "   if (document.getElementById('madblock'))"
+        "       return;"
         "   var URL = location.href;"
         "   var sites = new Array(); %s;"
         "   var public = '%s';"
@@ -60,7 +57,7 @@ adblock_build_js (const gchar* style,
         "   public += ' {display: none !important;}';"
         "   var mystyle = document.createElement('style');"
         "   mystyle.setAttribute('type', 'text/css');"
-        "   mystyle.setAttribute('title', 'madblock');"
+        "   mystyle.setAttribute('id', 'madblock');"
         "   mystyle.appendChild(document.createTextNode(public));"
         "   var head = document.getElementsByTagName('head')[0];"
         "   if (head) head.appendChild(mystyle);"
index 6ae124e15e3a17a9bdede8e44c3af0fa72d08290..721938365815d985f0b0f77dcddaa3cd6ee99702 100644 (file)
@@ -58,9 +58,12 @@ formhistory_prepare_js ()
         "%s"
         "window.addEventListener ('DOMContentLoaded',"
         "function () {"
+        "   if (document.getElementById('formhistory'))"
+        "       return;"
         "   initSuggestions ();"
         "   var mystyle = document.createElement('style');"
         "   mystyle.setAttribute('type', 'text/css');"
+        "   mystyle.setAttribute('id', 'formhistory');"
         "   mystyle.appendChild(document.createTextNode('%s'));"
         "   var head = document.getElementsByTagName('head')[0];"
         "   if (head) head.appendChild(mystyle);"