/*
* @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/' + branch : '/blob/' + branch);
var path = (ghPages[4] ? dirPath + ghPages[4] : '');
location.href = 'https://github.com/' + user + repo + path;
}