Add nightly.link buttons
This commit is contained in:
parent
7230f4c88d
commit
65ec104683
|
@ -16,6 +16,11 @@ to enable scripts to see emails again, inspired by
|
|||
|
||||
Hacky script to disable the client-side file limit per tab
|
||||
|
||||
## nightly.link buttons
|
||||
|
||||
A script to add [nightly.link](https://nightly.link) buttons on artifacts and
|
||||
build logs to view them without logging in
|
||||
|
||||
## Quizizz Force Show Answer
|
||||
|
||||
![A man yelling "I DON'T WANNA", followed by sign up/login boxes](https://gitlab.com/blankX/userscripts/-/raw/master/accounts.jpg)
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
// ==UserScript==
|
||||
// @name nightly.link buttons
|
||||
// @namespace blankie-scripts
|
||||
// @match http*://github.com/*/*/runs/*
|
||||
// @match http*://github.com/*/*/actions/runs/*
|
||||
// @grant none
|
||||
// @version 1.0
|
||||
// @author blankie
|
||||
// @run-at document-end
|
||||
// @description Show buttons to nightly.link on artifacts and build logs
|
||||
// ==/UserScript==
|
||||
|
||||
const INSTANCE_URL = "https://nightly.link";
|
||||
|
||||
function pageUpdated() {
|
||||
console.log("awo");
|
||||
let artifactsDiv = document.evaluate(
|
||||
"//div[@class = 'mx-0 mx-md-1'][h4[@class = 'text-bold']][div[@class = 'color-fg-muted text-small']]", document)
|
||||
.iterateNext();
|
||||
if (artifactsDiv !== null) {
|
||||
let artifactsButton = document.createElement("a");
|
||||
artifactsButton.className = "btn";
|
||||
// https://stackoverflow.com/a/17228764
|
||||
artifactsButton.style.float = "right";
|
||||
artifactsButton.innerText = "View on nightly.link";
|
||||
artifactsButton.href = INSTANCE_URL + location.pathname;
|
||||
artifactsDiv.prepend(artifactsButton);
|
||||
}
|
||||
|
||||
let githubLogsButton = document.querySelector("a.js-steps-dropdown-raw-logs");
|
||||
let logsHeader = document.querySelector("div.js-checks-log-toolbar");
|
||||
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";
|
||||
githubLogsButton.parentNode.append(nightlyLogsButton);
|
||||
} else if (logsHeader !== null) {
|
||||
let logsLink = document.createElement("a");
|
||||
logsLink.innerText = "View on nightly.link";
|
||||
logsLink.href = INSTANCE_URL + location.pathname + ".txt";
|
||||
logsHeader.append(logsLink);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: function properly on SPA-like navigation
|
||||
pageUpdated();
|
Loading…
Reference in New Issue