GitHub: remove Pulse and Graphs tabs
This commit is contained in:
parent
bee7ba2fef
commit
c6fd26b760
|
@ -2,45 +2,58 @@
|
||||||
let repoUrl = $("div.repohead-details-container > h1.public > strong[itemprop=name] > a").attr("href");
|
let repoUrl = $("div.repohead-details-container > h1.public > strong[itemprop=name] > a").attr("href");
|
||||||
let currentUser = $("ul.header-nav.float-right > li:last > a > img").attr("alt").substring(1);
|
let currentUser = $("ul.header-nav.float-right > li:last > a > img").attr("alt").substring(1);
|
||||||
|
|
||||||
// don't use the (ugly) new font
|
// remove pulse tab
|
||||||
// $("body").css("font-family", $("body").css("font-family").replace("BlinkMacSystemFont,", ""));
|
(function() {
|
||||||
|
let repoNav = $("nav.reponav");
|
||||||
|
if (repoNav.length <= 0) return;
|
||||||
|
|
||||||
|
repoNav.find(`a[href="${repoUrl}/pulse"]`).hide();
|
||||||
|
})();
|
||||||
|
|
||||||
|
// remove graphs tab
|
||||||
|
(function() {
|
||||||
|
let repoNav = $("nav.reponav");
|
||||||
|
if (repoNav.length <= 0) return;
|
||||||
|
|
||||||
|
repoNav.find(`a[href="${repoUrl}/graphs"]`).hide();
|
||||||
|
})();
|
||||||
|
|
||||||
// releases tab
|
// releases tab
|
||||||
(function() {
|
(function() {
|
||||||
let repoNav = $("nav.reponav");
|
let repoNav = $("nav.reponav");
|
||||||
if (repoNav.length > 0) {
|
if (repoNav.length <= 0) return;
|
||||||
let releasesUrl = repoUrl + "/releases";
|
|
||||||
let releasesTab = $("<a></a>");
|
|
||||||
releasesTab.attr("href", releasesUrl);
|
|
||||||
releasesTab.attr("data-selected-links", releasesUrl);
|
|
||||||
releasesTab.addClass("js-selected-navigation-item reponav-item");
|
|
||||||
|
|
||||||
let icon = "<svg aria-hidden=\"true\" class=\"octicon octicon-tag\" height=\"16\" version=\"1.1\" viewBox=\"0 0 14 16\" width=\"14\"><path d=\"M7.73 1.73C7.26 1.26 6.62 1 5.96 1H3.5C2.13 1 1 2.13 1 3.5v2.47c0 .66.27 1.3.73 1.77l6.06 6.06c.39.39 1.02.39 1.41 0l4.59-4.59a.996.996 0 0 0 0-1.41L7.73 1.73zM2.38 7.09c-.31-.3-.47-.7-.47-1.13V3.5c0-.88.72-1.59 1.59-1.59h2.47c.42 0 .83.16 1.13.47l6.14 6.13-4.73 4.73-6.13-6.15zM3.01 3h2v2H3V3h.01z\"></path></svg>";
|
let releasesUrl = repoUrl + "/releases";
|
||||||
releasesTab.append(icon);
|
let releasesTab = $("<a></a>");
|
||||||
|
releasesTab.attr("href", releasesUrl);
|
||||||
|
releasesTab.attr("data-selected-links", releasesUrl);
|
||||||
|
releasesTab.addClass("js-selected-navigation-item reponav-item");
|
||||||
|
|
||||||
releasesTab.append(" Releases");
|
let icon = "<svg aria-hidden=\"true\" class=\"octicon octicon-tag\" height=\"16\" version=\"1.1\" viewBox=\"0 0 14 16\" width=\"14\"><path d=\"M7.73 1.73C7.26 1.26 6.62 1 5.96 1H3.5C2.13 1 1 2.13 1 3.5v2.47c0 .66.27 1.3.73 1.77l6.06 6.06c.39.39 1.02.39 1.41 0l4.59-4.59a.996.996 0 0 0 0-1.41L7.73 1.73zM2.38 7.09c-.31-.3-.47-.7-.47-1.13V3.5c0-.88.72-1.59 1.59-1.59h2.47c.42 0 .83.16 1.13.47l6.14 6.13-4.73 4.73-6.13-6.15zM3.01 3h2v2H3V3h.01z\"></path></svg>";
|
||||||
|
releasesTab.append(icon);
|
||||||
|
|
||||||
let counter = $("<span></span>");
|
releasesTab.append(" Releases");
|
||||||
counter.text("0");
|
|
||||||
counter.addClass("counter");
|
|
||||||
releasesTab.append(counter);
|
|
||||||
|
|
||||||
repoNav.append(releasesTab);
|
let counter = $("<span></span>");
|
||||||
|
counter.text("0");
|
||||||
|
counter.addClass("counter");
|
||||||
|
releasesTab.append(counter);
|
||||||
|
|
||||||
$.ajax({
|
repoNav.find("a:last").before(releasesTab);
|
||||||
url: "https://api.github.com/repos" + repoUrl + "/releases",
|
|
||||||
dataType: "text",
|
|
||||||
success: (data) => {
|
|
||||||
let json = JSON.parse(data);
|
|
||||||
counter.text(json.length);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let pathParts = location.pathname.split("/");
|
$.ajax({
|
||||||
if (pathParts[pathParts.length - 1] == "releases" || pathParts[pathParts.length - 1] == "tags" || pathParts[pathParts.length - 2] == "releases" || pathParts[pathParts.length - 3] == "releases") {
|
url: "https://api.github.com/repos" + repoUrl + "/releases",
|
||||||
$("nav.reponav > span:first > a").removeClass("selected");
|
dataType: "text",
|
||||||
releasesTab.addClass("selected");
|
success: (data) => {
|
||||||
|
let json = JSON.parse(data);
|
||||||
|
counter.text(json.length);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
let pathParts = location.pathname.split("/");
|
||||||
|
if (pathParts[pathParts.length - 1] == "releases" || pathParts[pathParts.length - 1] == "tags" || pathParts[pathParts.length - 2] == "releases" || pathParts[pathParts.length - 3] == "releases") {
|
||||||
|
$("nav.reponav > span:first > a").removeClass("selected");
|
||||||
|
releasesTab.addClass("selected");
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue