javascript: (function () {
	var fork, present, star, button, form, forks, count;
	$('.pagehead-actions li').each(function () {
		var action = $(this).find('form').attr('action');
		if (action) {
			switch (action.split('/').pop()) {
			case 'fork':
				fork = $(this);
				present = true;
				break;
			case 'star':
				star = this;
				break;
			}
		}
	});
	if (!fork) {
		fork = $(star).clone();
	}
	button = fork.find('.minibutton');
	if (present) {
		button.focus();
		return;
	}
	form = fork.find('form');
	form.attr('action', form.attr('action').split('/').map(function (a) {
		return a === 'star' ? 'fork' : a;
	}).join('/'));
	button.html('<span class="octicon octicon-git-branch"></span>Fork');
	forks = $('.counter').filter(function () {
		var href = $(this).parent().attr('href');
		return href ? href.split('/').some(function (a) {
			return a === 'forks';
		}) : false;
	});
	count = fork.find('.social-count');
	count.html(forks.text() || 0);
	count.attr('href', forks.parent().attr('href'));
	$('.pagehead-actions li:last').parent().append(fork);
}());