Twinflater

    @@ -1,44 +1,50 @@ /* - * @title Followerlet - * @description cyclic shift Follower numbers + * @title Twinflater + * @description inflate Follower numbers on Twitter * @include http://twitter.com/* * @include https://twitter.com/* - * @contributor hayashit http://let.hatelabo.jp/hayashit/let/hJmfw-X-kZxq (Frok of) + * @contributor hayashit http://let.hatelabo.jp/hayashit/let/hJmfw-X-kZxq + * @contributor noromanba http://let.hatelabo.jp/noromanba/let/hJmfxcTY-eg2 (Fork of) * @license MIT License http://opensource.org/licenses/MIT * @javascript_url */ -// @javascript_url; for over the mixed-content blocker c.f. -// http://let.hatelabo.jp/help#at-javascript_url -// https://gist.github.com/noromanba/7015739 (ja) - -// mixed-content c.f. -// https://developer.mozilla.org/en-US/docs/Security/MixedContent -// https://support.google.com/chrome/answer/1342714 - - -// alt. c.f. -// http://hisayoshihayashi.com/followerlet/ -// http://let.hatelabo.jp/hayashit/let/hJmfw-aXqZps - // e.g. // https://twitter.com/twitter/ - -// TODO -// - unify quotation marks -// - independent from jQuery -(function(f, s) { - s = document.createElement("script"); - s.src = "//ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"; - s.onload = function() { - f(window.jQuery.noConflict(true)); - }; - document.body.appendChild(s); -})(function($) { - var f_dom = $('.ProfileNav-item--followers .ProfileNav-value'); - if( !f_dom.size() ) f_dom = $('.DashboardProfileCard-statLink[href="/followers"] .DashboardProfileCard-statValue'); - var follower = f_dom.text(); - var pad_f = Math.floor( parseInt(follower) * 100 + Math.random() * parseInt(follower) ); - f_dom.text( String(pad_f).replace( /(\d)(?=(\d\d\d)+(?!\d))/g, '$1,') ); -}); +(function () { + var followers = document.querySelector([ + 'a[href$="followers"] .ProfileNav-value', + '.DashboardProfileCard-statLink[href="/followers"] .DashboardProfileCard-statValue' // guess work + ]); + if (!followers) return; + + var persons = Number(followers.textContent.replace(/,/g, '')); + if (!persons) return; + + /* orig. + var inflated = (persons * 100) + ~~(Math.random() * persons); + /*/ + var inflated = (persons + ~~(Math.random() * 10000)); + //*/ + + followers.textContent = (function commify() { + if (Number.prototype.toLocaleString) { + return inflated.toLocaleString('en-US'); + } + + /* orig. + // classical comma sep c.f. + // http://www.din.or.jp/~ohzaki/perl.htm#NumberWithComma + // http://nanto.asablo.jp/blog/2007/12/07/2479257 + // http://blog.remora.cx/2011/01/commify-in-perl-and-javascript.html + return String(inflated).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); + /*/ + + // w/ word-boundary c.f. + // http://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#boundaries + return String(inflated).replace(/\B(?=(\d{3})+(?!\d))/g, ','); + //*/ + })(); +})();
  • /*
     * @title Twinflater
     * @description inflate Follower numbers on Twitter
     * @include http://twitter.com/*
     * @include https://twitter.com/*
     * @contributor hayashit  http://let.hatelabo.jp/hayashit/let/hJmfw-X-kZxq
     * @contributor noromanba http://let.hatelabo.jp/noromanba/let/hJmfxcTY-eg2 (Fork of)
     * @license MIT License http://opensource.org/licenses/MIT
     * @javascript_url
     */
    
    // e.g.
    // https://twitter.com/twitter/
    (function () {
        var followers = document.querySelector([
        'a[href$="followers"] .ProfileNav-value',
        '.DashboardProfileCard-statLink[href="/followers"] .DashboardProfileCard-statValue' // guess work
        ]);
        if (!followers) return;
    
        var persons = Number(followers.textContent.replace(/,/g, ''));
        if (!persons) return;
    
        /* orig.
        var inflated = (persons * 100) + ~~(Math.random() * persons);
        /*/
        var inflated = (persons + ~~(Math.random() * 10000));
        //*/
    
        followers.textContent = (function commify() {
            if (Number.prototype.toLocaleString) {
                return inflated.toLocaleString('en-US');
            }
    
            /* orig.
            // classical comma sep c.f.
            // http://www.din.or.jp/~ohzaki/perl.htm#NumberWithComma
            // http://nanto.asablo.jp/blog/2007/12/07/2479257
            // http://blog.remora.cx/2011/01/commify-in-perl-and-javascript.html
            return String(inflated).replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,');
            /*/
    
            // w/ word-boundary c.f.
            // http://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript
            // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp#boundaries
            return String(inflated).replace(/\B(?=(\d{3})+(?!\d))/g, ',');
            //*/
        })();
    })();
    
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2015/06/26 06:39:43 - 2015-06-26
  2. 2015/06/26 06:34:52 - 2015-06-26