Hatena::Let spam filter

    @@ -1,29 +1,46 @@ /* - * @title Hatena::Let SPAM Filter - * @description Hatena::Let の一覧から SPAM 投稿を消す(やっつけだけど) + * @title Hatena::Let spam filter + * @description hidden spam on Hatena::Let w/ Pager Extntion (as UserScript) * @include http://let.hatelabo.jp/* - * @license MIT License + * @contributor a-kuma3 http://let.hatelabo.jp/a-kuma3/let/hJme3Kz9g6Zc (Fork of) + * @license MIT License http://opensource.org/licenses/MIT * @javascript_url */ -(function () { - var forEach = Array.prototype.forEach; - var re1 = /^(https?:)+\s*$/, - re2 = /(https?:){2,}/; - var wipeout = function(ctx) { - forEach.call(document.body.querySelectorAll('div.codelist'), function (item) { - var source_block = item.querySelectorAll('pre.packed-source'); - if (source_block.length == 0) { - item.style.display = 'none'; - return; - } - var source = source_block[0]; - if (re1.exec(source.textContent) || re2.exec(source.textContent)) { - item.style.display = 'none'; + +// "SPAM" is ham, not spam + +// for Hatena Question c.f. +// http://let.hatelabo.jp/noromanba/let/hLHWrvnr8Mlx + +// spammer report c.f. +// http://ptech.g.hatena.ne.jp/noromanba/20141126/1417027101 +// http://ptech.g.hatena.ne.jp/noromanba/20150105/1420463835 + +(() => { + // TODO join/smart RegExp pattern + const URL_MONKEY = /^(https?:)+\s*$/; + const PROTOCOL_MONKEY= /(https?:){2,}/; + const body = document.body; + + const wipeout = (ctx) => { + Array.from(body.querySelectorAll('.codelist')).forEach((list) => { + const packed = list.querySelector('.packed-source'); + + if (!packed || + URL_MONKEY.test(packed.textContent) || + PROTOCOL_MONKEY.test(packed.textContent)) { + list.style.display = 'none'; return; } }); }; - wipeout(document.body); -})(); + wipeout(body); + // for Pager Extentions + new MutationObserver((records) => { + records.forEach((record) => { + wipeout(record.target); + }); + }).observe(body, { childList: true, subtree: true }); +})();
  • /*
     * @title Hatena::Let spam filter
     * @description hidden spam on Hatena::Let w/ Pager Extntion (as UserScript)
     * @include http://let.hatelabo.jp/*
     * @contributor a-kuma3 http://let.hatelabo.jp/a-kuma3/let/hJme3Kz9g6Zc (Fork of)
     * @license MIT License http://opensource.org/licenses/MIT
     * @javascript_url
     */
    
    // "SPAM" is ham, not spam
    
    // for Hatena Question c.f.
    // http://let.hatelabo.jp/noromanba/let/hLHWrvnr8Mlx
    
    // spammer report c.f.
    // http://ptech.g.hatena.ne.jp/noromanba/20141126/1417027101
    // http://ptech.g.hatena.ne.jp/noromanba/20150105/1420463835
    
    (() => {
        // TODO join/smart RegExp pattern
        const URL_MONKEY = /^(https?:)+\s*$/;
        const PROTOCOL_MONKEY= /(https?:){2,}/;
        const body = document.body;
    
        const wipeout = (ctx) => {
            Array.from(body.querySelectorAll('.codelist')).forEach((list) => {
                const packed = list.querySelector('.packed-source');
    
                if (!packed ||
                    URL_MONKEY.test(packed.textContent) ||
                    PROTOCOL_MONKEY.test(packed.textContent)) {
                    list.style.display = 'none';
                    return;
                }
            });
        };
        wipeout(body);
    
        // for Pager Extentions
        new MutationObserver((records) => {
            records.forEach((record) => {
                wipeout(record.target);
            });
        }).observe(body, { childList: true, subtree: true });
    })();
    
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2016/03/07 07:39:00 - 2016-03-07
  2. 2016/03/07 07:37:57 - 2016-03-07
  3. 2016/03/05 06:16:09 - 2016-03-05
  4. 2016/03/05 06:15:41 - 2016-03-05
  5. 2016/03/05 06:12:33 - 2016-03-05
  6. 2016/03/04 06:22:33 - 2016-03-04
  7. 2016/03/03 02:33:38 - 2016-03-03
  8. 2016/01/26 04:50:53 - 2016-01-26
  9. 2016/01/26 04:49:41 - 2016-01-26
  10. 2016/01/22 04:52:50 - 2016-01-22
  11. 2016/01/18 07:21:15 - 2016-01-18
  12. 2016/01/18 07:05:42 - 2016-01-18
  13. 2016/01/18 06:18:05 - 2016-01-18
  14. 2016/01/10 03:18:07 - 2016-01-10
  15. 2016/01/05 06:58:38 - 2016-01-05
  16. 2016/01/04 03:43:02 - 2016-01-04
  17. 2016/01/04 03:28:07 - 2016-01-04
  18. 2016/01/04 03:20:18 - 2016-01-04
  19. 2016/01/04 03:19:14 - 2016-01-04