[★+]

  • /*
     * @title [★+]
     * @description Hatena Star on the whole world
     * @include http://*
     * @include https://*
     * @contributor a-kuma3 http://let.hatelabo.jp/a-kuma3/let/hLHWypmkorgp
     * @license MIT License http://opensource.org/licenses/MIT
     * @javascript_url
     */
    
    // e.g.
    // http://d.hatena.com/
    // https://example.com/
    
    (() => {
        if (document.querySelector([
            'script[src*="//s.hatena.ne.jp/js/HatenaStar.js"]',
            'script[src*="//s.hatena.com/js/HatenaStar.js"]',
        ])) {
            // TBD re-append add container
            return;
        }
    
        const wall = document.head || document.body;// || document.documentElement;
        wall.appendChild(Object.assign(document.createElement('script'), {
            type: 'text/javascript',
            src: 'https://s.hatena.ne.jp/js/HatenaStar.js',
            onload: () => {
                // TBD other element
                const sol = document.body.querySelector([
                    Array.from(Array(6).keys(), n => 'h' + (n + 1))
                ]);
    
                // fallback to mobile c.f.
                // http://let.hatelabo.jp/noromanba/let/gYC-xcvQ3PTQew
                // http://ptech.g.hatena.ne.jp/noromanba/20170210/1486677295
                if (!sol) {
                    // https://gist.github.com/noromanba/d730ccf3ae5e6916cd60
                    // https://gist.github.com/noromanba/3705f2e9ebb8538328b2f3f9a6f1a9b3
                    const canonical = () => {
                        return (document.querySelector('head meta[property="og:url"][content]') || {}).content ||
                            (document.querySelector('head link[rel="canonical"][href]') || {}).href ||
                            location.href;
                    };
                    const canon = canonical();
    
                    window.open('https://s.hatena.ne.jp/mobile/entry?uri=' + encodeURIComponent(canon));
                    return;
                }
    
                const Hatena = window.Hatena;
    
                Hatena.Star.SiteConfig = {
                    entryNodes: {}
                };
    
                Hatena.Star.SiteConfig.entryNodes[sol.tagName] = {
                    uri: 'document.location',
                    title: 'document.title',
                    container: 'parent',
                };
    
                Hatena.Star.EntryLoader();
            },
        }));
    })();
    
    // alt c.f.
    // http://let.hatelabo.jp/yuta25/let/hJmdxKny-Mt7
    // http://let.hatelabo.jp/yuta25/let/hLHVyMC71a1v
    // https://github.com/wakaba/chrome-hatena-star-everywhere
    //  https://chrome.google.com/webstore/detail/hatena-star-everywhere/nbjckkhoenllbokoppppjagcckgaaaab
    // http://let.hatelabo.jp/noromanba/let/gYC-xcvQ3PTQew
    
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2017/02/19 17:49:19 - 2017-02-19
  2. 2017/02/19 08:28:08 - 2017-02-19
  3. 2017/02/19 04:18:14 - 2017-02-19
  4. 2017/02/19 04:16:36 - 2017-02-19