odyssey-scripts/github.js

98 lines
3.6 KiB
JavaScript

// GitHub CSS fixes
// version 1.1
// 2022-04-04
// Copyright (c) 2021 Created by Georgios Sokianos
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
//
// ==UserScript==
// @name GitHub CSS fixes
// @namespace none
// @description Fixes css in GitHub
// @include https://github.com/*
// @version $VER: GitHub CSS fixes 1.1 (04.04.2022)
// @url https://ko-fi.com/walkero
// ==/UserScript==
var css = ' \
.col-md-1 { width: 8.333333% !important; } \
.col-md-2 { width: 16.666667% !important; } \
.col-md-3 { width: 25% !important; } \
.col-md-4 { width: 33.333333% !important; } \
.col-md-5 { width: 41.666667% !important; } \
.col-md-6 { width: 50% !important; } \
.col-md-7 { width: 58.333333% !important; } \
.col-md-8 { width: 66.666667% !important; } \
.col-md-9 { width: 75% !important; } \
.col-md-10 { width: 83.333333% !important; } \
.col-md-11 { width: 91.666667% !important; } \
.col-md-12 { width: 100% !important; } \
.d-inline-flex { display: inline-block !important; } \
div.d-flex > div, \
div.d-lg-flex > div, \
ul.d-lg-flex > li, \
ul.d-flex > li { display: inline-block !important; vertical-align: top; } \
header nav { display: inline-block !important; } \
.Box--overlay, \
header nav li.d-block .dropdown-menu { background-color: white !important; } \
header nav li summary { color: black !important; } \
a.HeaderMenu-link { color: black !important; } \
summary.HeaderMenu-link svg { display: none !important; } \
input.header-search-input { color: black; border: #323232; } \
#responsive-meta-container > div > div { display: inline-block !important; } \
div.Layout > div { display: inline-block; } \
div.Layout-main { width: 70%; } \
div.Layout-sidebar { width: 26%; margin-left: 2%; vertical-align: top; } \
#repository-container-header { max-width: 1260px; margin: 10px auto; } \
#repository-container-header > nav { clear: both; } \
#repository-container-header > div > div { display: inline-block !important; width: 38%; } \
#repository-container-header > div > ul { display: inline-block !important; width: 60%; } \
div.Layout-main .Box-header, \
div.Layout-main .Box { border-color: #c1c1c1 !important; } \
div.js-details-container div.Box-row { border-color: #c1c1c1; clear: both; } \
.header-search input.header-search-input { float: left; border: 1px solid #c1c1c1; color: black; } \
';
var head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
head.appendChild(style);
style.type = 'text/css';
if (style.styleSheet){
// This is required for IE8 and below.
style.styleSheet.cssText = css;
} else {
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);
}
}
}