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
|
// @namespace blankie-scripts
|
||||||
// @match http*://github.com/*
|
// @match http*://github.com/*
|
||||||
// @grant none
|
// @grant none
|
||||||
// @version 1.2
|
// @version 1.2.1
|
||||||
// @author blankie
|
// @author blankie
|
||||||
// @run-at document-end
|
// @run-at document-end
|
||||||
// @description Show buttons to nightly.link on artifacts and build logs
|
// @description Show buttons to nightly.link on artifacts and build logs
|
||||||
|
@ -57,18 +57,35 @@ function addArtifactsButtonAndLinks(artifactsDiv) {
|
||||||
return true;
|
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) {
|
function addLogsButton(githubLogsButton, logsHeader) {
|
||||||
|
let logsUrl = INSTANCE_URL + getGithubJobsPath(logsHeader) + ".txt";
|
||||||
|
|
||||||
if (githubLogsButton !== null) {
|
if (githubLogsButton !== null) {
|
||||||
let nightlyLogsButton = document.createElement("a");
|
let nightlyLogsButton = document.createElement("a");
|
||||||
nightlyLogsButton.className = "pl-5 dropdown-item btn-link";
|
nightlyLogsButton.className = "pl-5 dropdown-item btn-link";
|
||||||
nightlyLogsButton.innerText = "View logs on nightly.link";
|
nightlyLogsButton.innerText = "View logs on nightly.link";
|
||||||
nightlyLogsButton.href = INSTANCE_URL + location.pathname + ".txt";
|
nightlyLogsButton.href = logsUrl;
|
||||||
githubLogsButton.parentNode.append(nightlyLogsButton);
|
githubLogsButton.parentNode.append(nightlyLogsButton);
|
||||||
return true;
|
return true;
|
||||||
} else if (logsHeader !== null) {
|
} else if (logsHeader !== null) {
|
||||||
let logsLink = document.createElement("a");
|
let logsLink = document.createElement("a");
|
||||||
logsLink.innerText = "View on nightly.link";
|
logsLink.innerText = "View on nightly.link";
|
||||||
logsLink.href = INSTANCE_URL + location.pathname + ".txt";
|
logsLink.href = logsUrl;
|
||||||
logsHeader.append(logsLink);
|
logsHeader.append(logsLink);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue