H::Q spam-filter

    @@ -2,7 +2,7 @@ * @title H::Q spam-filter * @description delete spam on Hatena Question w/ Auto Paging for UserScript * @include http://q.hatena.ne.jp/* - * @contributor a-kuma3 http://let.hatelabo.jp/a-kuma3/let/hLHWrsqN2qde (Frok of) + * @contributor a-kuma3 http://let.hatelabo.jp/a-kuma3/let/hLHWrsqN2qde (Fork of) * @license MIT http://opensource.org/licenses/MIT * @javascript_url */
  • /*
     * @title H::Q spam-filter
     * @description delete spam on Hatena Question w/ Auto Paging for UserScript
     * @include http://q.hatena.ne.jp/*
     * @contributor a-kuma3 http://let.hatelabo.jp/a-kuma3/let/hLHWrsqN2qde (Fork of)
     * @license MIT http://opensource.org/licenses/MIT
     * @javascript_url
     */
    
    // TBD delete by CSS for still paging
    // TODO unify other Hatena spam filter
    (function () {
        if (!/q\.hatena\.ne\.jp\/(:?touch\/)?/.test(location.hostname + location.pathname)) return;
    
        // prob url matching; unsupported except ASCII e.g.
        // http://q.hatena.ne.jp/1414927875
        var spamfilter = /^[- a-zA-Z0-9\\\[\](){}<>:;"'`?=/_.,@!~\n]+…?$/,
            forEach = Array.prototype.forEach;
        var wipeout = function (context) {
            // TBD choose parent node by children; using XPath or :scope and CSS4 ?selector
            forEach.call(context.querySelectorAll('.question-content-container'), function (link) {
                if (!spamfilter.test(link.textContent)) return;
    
                link.parentNode.style.display = 'none';
            });
        };
        wipeout(document.body);
    
        // https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
        var MutationObserver = window.MutationObserver || window.WebkitMutationObserver;
        new MutationObserver(function (records) {
            records.forEach(function (record) {
                wipeout(record.target);
            });
        }).observe(document.body, { childList: true, subtree: true });
    })();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2014/11/06 02:14:21 - 2014-11-06
  2. 2014/11/06 02:10:19 - 2014-11-06
  3. 2014/11/05 04:43:26 - 2014-11-05
  4. 2014/11/04 11:23:57 - 2014-11-04
  5. 2014/11/04 07:59:31 - 2014-11-04
  6. 2014/11/04 07:10:14 - 2014-11-04
  7. 2014/11/04 06:44:53 - 2014-11-04
  8. 2014/11/04 06:44:10 - 2014-11-04