Hatena::Let spam filter

    @@ -7,6 +7,9 @@ * @javascript_url */ +// UserScript +// https://gist.github.com/noromanba/e2fcfb01b2be8a12be79 + // feedback to Hatena c.f. // http://www.hatena.ne.jp/faq/q/let // http://let.hatelabo.jp/noromanba/let/hLHW16C50Zpx @@ -18,23 +21,25 @@ // http://ptech.g.hatena.ne.jp/noromanba/20141126/1417027101 // http://ptech.g.hatena.ne.jp/noromanba/20150105/1420463835 +'http://www.hatena.ne.jp/faq/q/let'; + (() => { // valid js url patterns; String, url(), RegExp c.f. // https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/RegExp // https://en.wikipedia.org/wiki/Regular_expression // http://yut.hatenablog.com/entry/20110305/1299318337 - // TBD \cX \xhh \uhhhh + // TBD \cX \xhh \uhhhh, template literal const invalidURL = /(?:^|[^"'\s\/^.\\dwstrnvfb0\[\]^|$()?:*{},=!])(?:https?:)+/i; const wipeout = (ctx) => { - Array.from(ctx.querySelectorAll('.codelist'), (list) => { + Array.from(ctx.querySelectorAll('.codelist'), list => { const packed = list.querySelector('.packed-source'); const title = (list.querySelector('.title .code-path') || {}); if (!packed || // XXX violate @require only src - title.textContent === 'no title' || - invalidURL.test(packed.textContent)) { - //* + invalidURL.test(packed.textContent) || + title.textContent === 'no title') { + /* list.style.display = 'none'; /*/ list.style.backgroundColor = 'red'; @@ -45,8 +50,8 @@ wipeout(document.body); // for Pager Extensions - new MutationObserver((records) => { - records.forEach((record) => { + new MutationObserver(records => { + records.forEach(record => { wipeout(record.target); }); }).observe(document.body, { childList: true, subtree: true });
  • /*
     * @title Hatena::Let spam filter
     * @description hidden spam on Hatena::Let w/ Pager Extension (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
     */
    
    // UserScript
    // https://gist.github.com/noromanba/e2fcfb01b2be8a12be79
    
    // feedback to Hatena c.f.
    // http://www.hatena.ne.jp/faq/q/let
    // http://let.hatelabo.jp/noromanba/let/hLHW16C50Zpx
    
    // Hatena Question spam-filter
    // 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
    
    'http://www.hatena.ne.jp/faq/q/let';
    
    (() => {
        // valid js url patterns; String, url(), RegExp c.f.
        //  https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/RegExp
        //  https://en.wikipedia.org/wiki/Regular_expression
        //  http://yut.hatenablog.com/entry/20110305/1299318337
        // TBD \cX \xhh \uhhhh, template literal
        const invalidURL = /(?:^|[^"'\s\/^.\\dwstrnvfb0\[\]^|$()?:*{},=!])(?:https?:)+/i;
    
        const wipeout = (ctx) => {
            Array.from(ctx.querySelectorAll('.codelist'), list => {
                const packed = list.querySelector('.packed-source');
                const title = (list.querySelector('.title .code-path') || {});
    
                if (!packed || // XXX violate @require only src
                    invalidURL.test(packed.textContent) ||
                    title.textContent === 'no title') {
                    /*
                    list.style.display = 'none';
                    /*/
                    list.style.backgroundColor = 'red';
                    //*/
                }
            });
        };
        wipeout(document.body);
    
        // for Pager Extensions
        new MutationObserver(records => {
            records.forEach(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. 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