Hatena /archive

    @@ -7,38 +7,34 @@ * @include http://*.hatenablog.tld/* * @include http://*.hatenadiary.tld/* * @include http://*.hateblo.jp/* + * @include http://* * @license MIT License http://nrm.mit-license.org/2012 - * @require + * @require */ (function (Hatena) { - var id = (function () { - if (typeof Hatena !== 'object') return ''; - - if (Hatena.Author && Hatena.Author.name) { - return Hatena.Author.name; - } - if (Hatena.Diary && Hatena.Diary.Author) { - return Hatena.Diary.Author; - } - - return ''; - })(); - - var topPage, - origin = location.origin || location.protocol + '//' + location.hostname; - + var isHatenaBlog = function () { + return (Hatena.Author && Hatena.Author.name) || + (Hatena.Diary && Hatena.Diary.Author); + }; + // strict HatenaID: /[a-zA-Z][\w-]{1,30}[a-zA-Z\d]/ // loosed HatenaID: /[\w-]+/ - if (/^(?:d|[\w-]+\.g)\.hatena\.ne\.jp$/.test(location.hostname)) { - topPage = origin + '/' + (id || location.pathname.split[1]); - } else if (/^(?:[\w-]+\.(?:hatena(?:blog\.(?:com|jp)|diary\.(?:com|jp))|hateblo\.jp)$)/.test(location.hostname)) { - topPage = origin; - } else if (id || (Hatena && Hatena.Diary)) { - // prob. Hatena Blog original domain - topPage = origin; - } else { + // Hatena DiaryID: /[\w-+]+/ + var origin = location.origin || location.protocol + '//' + location.hostname, + diaryId; + if ((diaryId = (/^https?:\/\/(?:d|[\w-]+\.g)\.hatena\.ne\.jp\/([\w-+]+)/.exec(location.href) || [])[1])) { + location.href = origin + '/' + diaryId + '/archive'; + return; // for Firefox + } + + if (/^https?:\/\/(?:[\w+]+\.(?:hatena(?:blog\.(?:com|jp)|diary\.(?:com|jp))|hateblo\.jp))/.test(location.hostname)) { + location.href = origin + '/archive'; + return; + } + + // Hatena Blog original domain + if (isHatenaBlog) { + location.href = origin; return; } - - location.href = topPage + '/archive'; })(window.Hatena || {});
  • /*
     * @title Hatena /archive
     * @description Go to archive on H::D, H::G and Hatena Blog
     * @include http://d.hatena.ne.jp/*
     * @include http://*.g.hatena.ne.jp/*
     * @include https://*.g.hatena.ne.jp/*
     * @include http://*.hatenablog.tld/*
     * @include http://*.hatenadiary.tld/*
     * @include http://*.hateblo.jp/*
     * @include http://*
     * @license MIT License http://nrm.mit-license.org/2012
     * @require
     */
    (function (Hatena) {
        var isHatenaBlog = function () {
            return (Hatena.Author && Hatena.Author.name) ||
                (Hatena.Diary && Hatena.Diary.Author);
        };
    
        // strict HatenaID: /[a-zA-Z][\w-]{1,30}[a-zA-Z\d]/
        // loosed HatenaID: /[\w-]+/
        // Hatena DiaryID:  /[\w-+]+/
        var origin = location.origin || location.protocol + '//' + location.hostname,
            diaryId;
        if ((diaryId = (/^https?:\/\/(?:d|[\w-]+\.g)\.hatena\.ne\.jp\/([\w-+]+)/.exec(location.href) || [])[1])) {
            location.href = origin + '/' + diaryId + '/archive';
            return; // for Firefox
        }
    
        if (/^https?:\/\/(?:[\w+]+\.(?:hatena(?:blog\.(?:com|jp)|diary\.(?:com|jp))|hateblo\.jp))/.test(location.hostname)) {
            location.href = origin + '/archive';
            return;
        }
    
        // Hatena Blog original domain
        if (isHatenaBlog) {
            location.href = origin;
            return;
        }
    })(window.Hatena || {});
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2012/07/21 01:44:16 - 2012-07-21
  2. 2012/07/21 01:42:56 - 2012-07-21
  3. 2012/05/08 04:01:45 - 2012-05-08
  4. 2012/04/03 11:06:42 - 2012-04-03
  5. 2012/03/31 06:36:10 - 2012-03-31
  6. 2012/03/29 13:07:34 - 2012-03-29
  7. 2012/03/29 12:36:02 - 2012-03-29
  8. 2012/03/29 12:34:59 - 2012-03-29
  9. 2012/03/29 12:34:42 - 2012-03-29