[Xfce4-commits] <midori:master> Use id to avoid inserting adblock/ form history style more than once

Christian Dywan noreply at xfce.org
Wed Dec 23 22:04:03 CET 2009


Updating branch refs/heads/master
         to 05601be63552575c7580ff4a45ef008fe2e04138 (commit)
       from 973e4aa90792250ce4a6636e3150b40e210fed61 (commit)

commit 05601be63552575c7580ff4a45ef008fe2e04138
Author: Alexander Butenko <a.butenka at gmail.com>
Date:   Wed Dec 23 15:35:09 2009 +0100

    Use id to avoid inserting adblock/ form history style more than once

 extensions/adblock.c     |    9 +++------
 extensions/formhistory.c |    3 +++
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/extensions/adblock.c b/extensions/adblock.c
index f1c36c2..cb5162d 100644
--- a/extensions/adblock.c
+++ b/extensions/adblock.c
@@ -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);"
diff --git a/extensions/formhistory.c b/extensions/formhistory.c
index 6ae124e..7219383 100644
--- a/extensions/formhistory.c
+++ b/extensions/formhistory.c
@@ -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);"



More information about the Xfce4-commits mailing list