Class renaming and adblock

85 views
Skip to first unread message

rhysbre...@gmail.com

unread,
Aug 31, 2012, 3:41:48 PM8/31/12
to closure-style...@googlegroups.com
looks like there is a popular adblock filter that hides elements with the classname of Ad, we just came across this.

easy fix, just put in .Ad{zoom:1} to your gss file so that no class is renamed to Ad

rhysbre...@gmail.com

unread,
Aug 31, 2012, 4:32:32 PM8/31/12
to closure-style...@googlegroups.com, rhysbre...@gmail.com
you also need --excluded_classes_from_renaming Ad in the command line

rhysbre...@gmail.com

unread,
Aug 31, 2012, 4:49:50 PM8/31/12
to closure-style...@googlegroups.com, rhysbre...@gmail.com
actually looks like I'm wrong - this won't fix it at all. renaming still uses .Ad even when there is already a .Ad class defined and even if you tell it to ignore. This should probably be a bug

rhysbre...@gmail.com

unread,
Aug 31, 2012, 5:04:16 PM8/31/12
to closure-style...@googlegroups.com, rhysbre...@gmail.com

kien...@catch.com

unread,
May 30, 2013, 8:37:31 PM5/30/13
to closure-style...@googlegroups.com, rhysbre...@gmail.com
On Friday, August 31, 2012 12:41:49 PM UTC-7, rhysbre...@gmail.com wrote:
looks like there is a popular adblock filter that hides elements with the classname of Ad, we just came across this.

easy fix, just put in .Ad{zoom:1} to your gss file so that no class is renamed to Ad


A workaround for this particular issue is to patch the stylesheet compiler with knowledge of class names it should avoid:

diff --git a/src/com/google/common/css/MinimalSubstitutionMap.java b/src/com/google/common
index fb46c0a..d36972b 100644
--- a/src/com/google/common/css/MinimalSubstitutionMap.java
+++ b/src/com/google/common/css/MinimalSubstitutionMap.java
@@ -108,12 +108,26 @@ public class MinimalSubstitutionMap implements SubstitutionMap {
     this.renamedCssClasses = Maps.newHashMap();
   }
 
+  /**
+   * TODO: Make the list of excluded strings here settable via
+   * command-line.  Implement exclusion checking for the other
+   * SubstitutionMap classes as appropriate.
+   *
+   * @param value candidate target value
+   * @return True if this value should be excluded.
+   */
+  private boolean excludedString(String value) {
+      return ("ad".equals(value) || "AD".equals(value) || "Ad".equals(value) || "aD".equa
+  }
+
   /** {@inheritDoc} */
   @Override
   public String get(String key) {
     String value = renamedCssClasses.get(key);
     if (value == null) {
-      value = toShortString(lastIndex++);
+      do {
+        value = toShortString(lastIndex++);
+      } while (excludedString(value));
       renamedCssClasses.put(key, value);
     }
     return value;
 
Reply all
Reply to author
Forward
0 new messages