Feedly Pro ($99) に申し込んだことだしゴミみたいなユーザースクリプトを作った

\Pro Plan/
feedly_pro

つい最近、Feedlyが月額$5の有料プランを先着5000人だったかで$99払えば生涯使えるというのをやってたので申し込んだのだけど、このプレミアム感のなさに驚愕してゴミみたいなユーザースクリプトを作った。

userscripts.org に絶対ありそうな広告エントリーやら必要なさそうなのを非表示にするやつの簡易版。

好んで使ってたDOMNodeInsertedが廃止予定らしく、MutationObserverというのを使ってるので古いブラウザだと全く動かないしエラーでます。
正直、MutationObserverが使いたかっただけ。

ダウンロード: feedly_filter.user.js

// ==UserScript==
// @name           Feedly Filter
// @description    広告エントリーを非表示にするしか能がない
// @include        http://cloud.feedly.com/*
// @include        https://cloud.feedly.com/*
// ==/UserScript==

(function() {
    var feedly = {
        titles: [
            /^(PR:|AD:|INFO:|【PR】)/i,
            /管理人のブックマーク/,
            /^ダイジェストニュース/,
            /bokete/
        ],
        urls: [
        ],
        observer: new MutationObserver(function(mutations) {
            mutations.forEach(function(mutation) {
                var elm = mutation.addedNodes[0];
                if (elm && elm.nodeName == 'DIV') {
                    feedly.filterEntry(elm);
              }
            });
        }),
        init: function() {
            // this.debug(' init()');
            this.observer.observe(document.body, {childList: true, subtree: true});
            window.addEventListener('beforeunload', this, true);
        },
        handleEvent: function(event) {
            if (event.type == 'beforeunload') {
                // this.debug(' disconnect()');
                this.observer.disconnect();
                window.removeEventListener('beforeunload', this, true);
            }
        },
        debug: function() {
            var i, l = arguments[0];
            for (i = 1; i < arguments.length; i++) {
                if (arguments[i]) l += ', ' + arguments[i];
            }
            unsafeWindow.console.log('[userscript][feedly_filter]' + l);
        },
        filterEntry: function(elm) {
            var a, i, title, read = false;
            if (!elm.className || !elm.className.contains('u0Entry')) return;
            a = elm.getElementsByClassName('title')[0];
            if (a.className == 'title read') {
                read = true;
            }
            title = elm.getAttribute('data-title');
            for (i = 0; i < this.titles.length; i++) {
                if (!this.titles[i].test(title)) continue;
                // this.debug('[hide] ' + title);
                this.hide(elm, read);
                break;
            }
        },
        hide: function(elm, read) {
            var div = elm.getElementsByClassName('condensedTools')[0],
                img, e;

            if (read) {
                elm.style.display = 'none';
                return;
            }
            if (!div) return;
            img = div.getElementsByTagName('img')[1];
            if (img.getAttribute('title') == 'Mark as read and hide') {
                e = document.createEvent('MouseEvents');
                e.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
                img.dispatchEvent(e);
            }
        }
    };
    feedly.init();
})();