Github Rawgit Button

An userscript to add "Rawgit" button on github.

Verze ze dne 10. 10. 2014. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name		Github Rawgit Button
// @namespace	eight04.blogspot.com
// @description	An userscript to add "Rawgit" button on github.
// @include		https://github.com/*
// @version		1.1
// @grant 		none
// ==/UserScript==

"use strict";

function replace(){
	var btn = document.querySelector("#raw-url");
	if (!btn || btn.classList.contains("rawgit")) {
		return;
	}
	
	var url = location.href.replace("github.com", "rawgit.com");
	url = url.replace("/blob/", "/");
	
	var newBtn = document.createElement("a");
	newBtn.href = url;
	newBtn.className = "minibutton";
	newBtn.textContent = "Rawgit";
	
	btn.parentNode.insertBefore(newBtn, btn.nextSibling);
	
	btn.classList.add("rawgit");
}

var container = document.querySelector("#js-repo-pjax-container");
if (container) {
	new MutationObserver(function(e){
		replace();
	}).observe(container, {childList: true, subtree: true});
}

replace();