Update nightly.link buttons to version 1.2.1
- Fix viewing job logs
This commit is contained in:
parent
59fe815206
commit
a0ffce4d6a
|
@ -3,7 +3,7 @@
|
|||
// @namespace blankie-scripts
|
||||
// @match http*://github.com/*
|
||||
// @grant none
|
||||
// @version 1.2
|
||||
// @version 1.2.1
|
||||
// @author blankie
|
||||
// @run-at document-end
|
||||
// @description Show buttons to nightly.link on artifacts and build logs
|
||||
|
@ -57,18 +57,35 @@ function addArtifactsButtonAndLinks(artifactsDiv) {
|
|||
return true;
|
||||
}
|
||||
|
||||
// https://github.com/EbookFoundation/free-programming-books/actions/runs/3213752190/jobs/5253657996
|
||||
// https://github.com/kotatogram/kotatogram-desktop/actions/runs/3231502508/jobs/5291098845
|
||||
function getGithubJobsPath(logsHeader) {
|
||||
let timestampElement = logsHeader.querySelector(".CheckRun-header-timestamp");
|
||||
if (timestampElement === null) {
|
||||
return location.pathname;
|
||||
}
|
||||
let headerUrl = timestampElement.getAttribute("data-url");
|
||||
if (headerUrl === null) {
|
||||
return location.pathname;
|
||||
}
|
||||
let jobLogsUrl = new URL(headerUrl, location);
|
||||
return jobLogsUrl.pathname.replace(/\/header\/*$/, "");
|
||||
}
|
||||
|
||||
function addLogsButton(githubLogsButton, logsHeader) {
|
||||
let logsUrl = INSTANCE_URL + getGithubJobsPath(logsHeader) + ".txt";
|
||||
|
||||
if (githubLogsButton !== null) {
|
||||
let nightlyLogsButton = document.createElement("a");
|
||||
nightlyLogsButton.className = "pl-5 dropdown-item btn-link";
|
||||
nightlyLogsButton.innerText = "View logs on nightly.link";
|
||||
nightlyLogsButton.href = INSTANCE_URL + location.pathname + ".txt";
|
||||
nightlyLogsButton.href = logsUrl;
|
||||
githubLogsButton.parentNode.append(nightlyLogsButton);
|
||||
return true;
|
||||
} else if (logsHeader !== null) {
|
||||
let logsLink = document.createElement("a");
|
||||
logsLink.innerText = "View on nightly.link";
|
||||
logsLink.href = INSTANCE_URL + location.pathname + ".txt";
|
||||
logsLink.href = logsUrl;
|
||||
logsHeader.append(logsLink);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue