/*
 * Rules for identifying ads on individual domains.
 *
 * match: Returns true if the current article is sponsored.
 * getSponsor: Returns the name of the sponsor. Null if unknown.
 *
 */
window.AD_DETECTOR_RULES = {
  'buzzfeed.com': [
    {
      match: function() {
        var elts = document.getElementsByClassName('author_title');
        if (elts.length > 0) {
          return elts[0].innerHTML.indexOf('Brand Publisher') > -1;
        }
        return false;
      },
      getSponsor: function() {
        var elts = document.querySelectorAll('[rel="author"]')
        if (elts.length > 0) {
          return elts[0].innerHTML.trim()
        }
        return null;
      },
    },
  ],
  'deadspin.com': [
    {
      match: function() {
        return document.getElementsByClassName('sponsored-label').length > 0;
      },
      getSponsor: function() {
        return null;
      },
    },
  ],
  'gawker.com': [
    {
      match: function() {
        return document.getElementsByClassName('sponsored-label').length > 0;
      },
      getSponsor: function() {
        return null;
      },
    },
  ],
  'paidpost.nytimes.com': [
    {
      match: function() {
        return true;
      },
      getSponsor: function() {
        var paidElts = document.getElementsByClassName('paid-top-border-txt');
        if (paidElts.length < 1) {
          return null;
        }
        return paidElts[0].innerHTML.replace('PAID FOR AND POSTED BY ', '');
      },
    },
  ],
  'slate.com': [
    {
      match: function() {
        return document.getElementsByClassName('provided-by').length > 0;
      },
      getSponsor: function() {
        return null;
      },
    },
  ],
  'theatlantic.com': [
    {
      match: function() {
        return document.getElementsByClassName('sponsor-warning').length > 0;
      },
      getSponsor: function() {
        return null;
      },
    },
  ],
};

@@ -230,32 +230,115 @@
 d.com': %5B%0A    %7B%0A
+      // Example: http://www.buzzfeed.com/bravo/ways-to-up-your-online-dating-game%0A
       match: fun
@@ -792,32 +792,134 @@
 n.com': %5B%0A    %7B%0A
+      // Example: http://deadspin.com/5969545/exclusive-could-this-be-chris-pauls-secret-twin-brother%0A
       match: fun
@@ -1095,28 +1095,495 @@
 %0A  '
-gawker.com': %5B%0A    %7B
+forbes.com': %5B%0A    %7B%0A      // Example: http://www.forbes.com/sites/fidelity/2014/04/29/should-you-accept-your-employers-pension-buyout-offer/%0A      match: function() %7B%0A        return document.getElementsByClassName('brandvoice').length %3E 0;%0A      %7D,%0A      getSponsor: function() %7B%0A        return document.getElementsByClassName('brandvoice')%5B0%5D.textContent;%0A      %7D,%0A    %7D,%0A  %5D,%0A  'gawker.com': %5B%0A    %7B%0A      // Example: http://gawker.com/5974129/how-to-transform-into-a-total-nerd-babe/
 %0A   
@@ -1791,32 +1791,130 @@
 s.com': %5B%0A    %7B%0A
+      // Example: http://paidpost.nytimes.com/vacheron-constantin/transmitting-craftsmanship.html%0A
       match: fun
@@ -2244,32 +2244,143 @@
 e.com': %5B%0A    %7B%0A
+      // Example: http://www.slate.com/articles/news_and_politics/uc/2014/06/living_forever_the_right_way.html%0A
       match: fun
@@ -2570,24 +2570,148 @@
 m': %5B%0A    %7B%0A
+      // Example: http://www.theatlantic.com/sponsored/ibm-big-data/big-data-grows-new-role-emerges-chief-data-officer/102/%0A
       match:
@@ -2884,11 +2884,545 @@
 %7D,%0A  %5D,%0A
+  'theonion.com': %5B%0A    %7B%0A      // Example: http://www.theonion.com/sponsored/woman-going-to-take-quick-break-after-filling-out,85/%0A      match: function() %7B%0A        return document.getElementById('sponsored-box') !== null;%0A      %7D,%0A      getSponsor: function() %7B%0A        var elts = document.querySelectorAll('#sponsor-explanation-text h1');%0A        if (elts.length %3C 1) %7B%0A          return null;%0A        %7D%0A        var text = elts%5B0%5D.lastChild.textContent;%0A        return text.slice(3, text.lastIndexOf('%C2%B7') - 1);%0A      %7D,%0A    %7D,%0A  %5D,%0A
 %7D;%0A

Add examples, forbes, theonion