var addHeadingAnchors = {

  init: function (selector) {
    this.target = document.querySelector(selector);
    if (this.target) {
      this.addAnchorsToHeadings();
    }
  },

  addAnchorsToHeadings: function () {
    var headings = this.target.querySelectorAll('h1, h2, h3, h4, h5, h6'),
      id;

    headings.forEach(function (heading) {
      if (id = heading.id) {
        var anchor = this.createAnchor(id);
        heading.appendChild(anchor);
      }
    }.bind(this));
  },

  createAnchor: function (id) {
    var anchor = document.createElement('a'),
      anchorText = document.createTextNode('¶'),
      attributes = {
        href: id,
        class: 'headerLink',
        title: 'Permalink to this headline'
      };

    anchor.appendChild(anchorText);

    for (var attr in attributes) {
      anchor.setAttribute(attr, attributes[attr]);
    }

    return anchor;
  }

};

@@ -218,16 +218,89 @@
     var 
+selectorString = 'h1%5Bid%5D, h2%5Bid%5D, h3%5Bid%5D, h4%5Bid%5D, h5%5Bid%5D, h6%5Bid%5D',%0A      
 headings
@@ -335,44 +335,23 @@
 All(
-'h1, h2, h3, h4, h5, h6'),%0A      id;
+selectorString)
 %0A%0A  
@@ -394,39 +394,8 @@
 ) %7B%0A
-      if (id = heading.id) %7B%0A  
     
@@ -427,16 +427,24 @@
 eAnchor(
+heading.
 id);%0A   
@@ -442,26 +442,24 @@
 .id);%0A      
-  
 heading.appe
@@ -479,16 +479,8 @@
 r);%0A
-      %7D%0A
     
@@ -902,12 +902,11 @@
 or;%0A  %7D%0A
-%0A
 %7D;%0A

Change selector string so the query only returns headings with ids