Added a link to download the branch as a ZIP file
This commit is contained in:
parent
1e2ab13d1e
commit
23b694502d
34
github.js
34
github.js
|
@ -1,6 +1,6 @@
|
||||||
// GitHub CSS fixes
|
// GitHub CSS fixes
|
||||||
// version 1.0
|
// version 1.1
|
||||||
// 2021-12-23
|
// 2022-04-04
|
||||||
// Copyright (c) 2021 Created by Georgios Sokianos
|
// Copyright (c) 2021 Created by Georgios Sokianos
|
||||||
// Released under the GPL license
|
// Released under the GPL license
|
||||||
// http://www.gnu.org/copyleft/gpl.html
|
// http://www.gnu.org/copyleft/gpl.html
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
// @namespace none
|
// @namespace none
|
||||||
// @description Fixes css in GitHub
|
// @description Fixes css in GitHub
|
||||||
// @include https://github.com/*
|
// @include https://github.com/*
|
||||||
// @version $VER: GitHub CSS fixes 1.0 (23.12.2021)
|
// @version $VER: GitHub CSS fixes 1.1 (04.04.2022)
|
||||||
// @url https://ko-fi.com/walkero
|
// @url https://ko-fi.com/walkero
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
|
@ -67,3 +67,31 @@ if (style.styleSheet){
|
||||||
style.appendChild(document.createTextNode(css));
|
style.appendChild(document.createTextNode(css));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.onload = function () {
|
||||||
|
var canonicalElem = document.querySelector("link[rel='canonical']");
|
||||||
|
if (canonicalElem !== null) {
|
||||||
|
var canonicalUrl = canonicalElem.href;
|
||||||
|
var container = document.getElementById("repository-container-header");
|
||||||
|
var archiveText = document.createTextNode("Download ZIP");
|
||||||
|
var archiveUrl = canonicalUrl;
|
||||||
|
|
||||||
|
if (canonicalUrl.indexOf("tree") > -1) {
|
||||||
|
archiveUrl = archiveUrl.replace("tree", "archive/refs/heads");
|
||||||
|
} else {
|
||||||
|
var branchElem = document.querySelector("span[data-menu-button]");
|
||||||
|
if (branchElem !== null) {
|
||||||
|
archiveUrl += "/archive/refs/heads/" + branchElem.textContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (archiveUrl != canonicalUrl) {
|
||||||
|
var archiveLink = document.createElement("a");
|
||||||
|
archiveLink.appendChild(archiveText);
|
||||||
|
archiveLink.title = "Download as a ZIP file";
|
||||||
|
archiveLink.href = archiveUrl + ".zip";
|
||||||
|
|
||||||
|
container.appendChild(archiveLink);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue