On 6/16/15 4:34 PM, Brent Montrose wrote:
Thanks for the quick reply to my earlier email ("A few questions about
Content Blocking Extensions in Safari 9").

I have another question regarding content hiding and the use of the
"if-domain" option in the "trigger" field.  I would like some
clarification regarding the usage of the "if-domain" and the
"unless-domain" options.

Below is some sample code which successfully hides a few ads on slashdot.org.

      var rules = [];
       //general rule 1
       rules.push({
         "action": {
             "selector": ".adwrap",
             "type": "css-display-none"
         },
         "trigger": {
             "url-filter": ".*"
         }
       });
       //general rule 2
       rules.push({
         "action": {
             "selector": "div[id^=\"div-gpt-ad-\"]",
             "type": "css-display-none"
         },
         "trigger": {
             "url-filter": ".*"
         }
       });
       //site specific rule 3
       rules.push({
         "action": {
           "selector": "#banner-wrap",
           "type": "css-display-none"
         },
         "trigger": {
           "url-filter": ".*",
          // "if-domain": ["slashdot.org"]
          }
       });
       safari.extension.setContentBlocker(rules);

The above code works, and successfully hides the ads.  However, if the
"if-domain" line is uncommented in site specific rule 3 above, the ads
are displayed.  Is there a way to write the above three rules so that
the ads on slashdot.org are hidden?  In other words, I would like:
- all three rules applied to slashdot.org
- rule 1 and 2 applied to any other site / domain
- only rule 3 applied to slashdot.org

Is there a way to write the rules to do this?  If so, how?

Your code looks right for that.

We are quite puzzled that it does not work for you. Alex and I tried your rules locally and it seems to work fine when "if-domain" is enabled.

We have a WebKit version that is a bit more recent than the first beta so it could be that you are hitting a bug we recently fixed.

Can you please file a bug report on http://bugreport.apple.com and attach your extension? It would be useful to confirm it works on the latest WebKit.

Benjamin
_______________________________________________
webkit-help mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-help

Reply via email to