bdforbes
11/15/2017 - 3:02 AM

Add a button to the feedly All list that removes sponsored ads

Add a button to the feedly All list that removes sponsored ads

// ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://feedly.com/i/latest
// @grant        none
// ==/UserScript==

var removeAds = function() {
  var entries = document.getElementsByClassName("entry");

  for (var i = 0; i < entries.length; ++i) {
    var entry = entries[i];
    var children = entry.children;

    for (var j=0; j<children.length; ++j) {
      var child = children[j];

      if (child.nodeName=='SPAN' && child.innerText=='Sponsored') {
        console.log('Removing entry with inner text:\n\n'+entry.innerText);
        entry.parentElement.removeChild(entry);
        return;
      }
    }
  }
};

var foo = function() {
    var element = document.createElement('input');
    element.type = 'button';
    element.id = 'btnRemove';
    element.value = 'Remove ads';
    element.onclick = removeAds;
    var cont = document.getElementsByClassName('list-entries')[0].parentElement;
    cont.insertBefore(element, cont.children[1]);
};


(function() {
    'use strict';
    setTimeout(foo, 3000);
})();