GitHub←→gh-pages

    @@ -1,10 +1,10 @@ /* * @title GitHub←→gh-pages - * @description GitHubリポジトリとGitHub Pagesを行き来する + * @description GitHubリポジトリとGitHub Pagesを行き来する。ブランチ名はgh-pages固定 * @license MIT License * @javascript_url */ - +var branch = 'gh-pages'; var gh = location.href.match(/^https:\/\/github\.com\/([^\/]+)\/([^\/]+)(\/[^\/]+\/[^\/]+(.*))?/); if(gh !== null){ @@ -17,7 +17,7 @@ if(ghPages){ var user = ghPages[1]; var repo = (ghPages[3] ? '/' + ghPages[3] : ''); - var dirPath = ghPages[5] ? '/tree/master' : '/blob/master'; + var dirPath = (ghPages[5] ? '/tree/' : '/blob/') + branch; var path = (ghPages[4] ? dirPath + ghPages[4] : ''); location.href = 'https://github.com/' + user + repo + path; }
  • /*
     * @title GitHub←→gh-pages
     * @description GitHubリポジトリとGitHub Pagesを行き来する。ブランチ名はgh-pages固定
     * @license MIT License
     * @javascript_url
     */
    var branch = 'gh-pages';
    
    var gh = location.href.match(/^https:\/\/github\.com\/([^\/]+)\/([^\/]+)(\/[^\/]+\/[^\/]+(.*))?/);
    if(gh !== null){
      var user =  gh[1];
      var repo =  gh[2];
      var path = (gh[4] ? gh[4] : '');
      location.href = 'https://' +user + '.github.io/' +repo + path;
    }
    var ghPages = location.href.match(/^https:\/\/([^.]+)\.github\.io\/(([^\/+])(.*?))?(\/?)([#?].*)$/);
    if(ghPages){
      var user = ghPages[1];
      var repo = (ghPages[3] ? '/' + ghPages[3] : '');
      var dirPath = (ghPages[5] ? '/tree/' : '/blob/') + branch;
      var path = (ghPages[4] ? dirPath + ghPages[4] : '');
      location.href = 'https://github.com/' + user + repo + path;
    }
    
    
      
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2017/06/10 18:56:26 - 2017-06-10
  2. 2017/06/10 18:52:50 - 2017-06-10
  3. 2017/06/10 18:50:39 - 2017-06-10
  4. 2017/06/10 18:48:40 - 2017-06-10