|
4 | 4 | // @run-at document-idle |
5 | 5 | // ==/UserScript== |
6 | 6 |
|
7 | | -const repo = "Defelo/nixpkgs-review-gha"; |
| 7 | +const user = document.querySelector("header.GlobalNav button[data-login]")?.getAttribute("data-login") ?? null; |
| 8 | + |
| 9 | +const repo = user ? `${user}/nixpkgs-review-gha` : null; |
8 | 10 |
|
9 | 11 | const reviewDefaults = ({ title, commits, labels, author, authoredByMe, hasLinuxRebuilds, hasDarwinRebuilds }) => { |
10 | 12 | const darwinSandbox = "relaxed"; |
@@ -60,8 +62,7 @@ const getPrDetails = pr => { |
60 | 62 | ); |
61 | 63 | const labels = [...document.querySelectorAll("div.js-issue-labels > a")].map(x => x.innerText); |
62 | 64 | const author = document.querySelector(".js-discussion > :first-child a.author").href.split("/").at(-1); |
63 | | - const self = document.querySelector("header.GlobalNav button[data-login]").getAttribute("data-login"); |
64 | | - const authoredByMe = author === self; |
| 65 | + const authoredByMe = author === user; |
65 | 66 | const hasLinuxRebuilds = !labels.some(l => /rebuild-linux: 0$/.test(l)); |
66 | 67 | const hasDarwinRebuilds = !labels.some(l => /rebuild-darwin: 0$/.test(l)); |
67 | 68 | const state = document |
@@ -125,7 +126,7 @@ const setupPrPage = async () => { |
125 | 126 | const pr = match[1]; |
126 | 127 | const actions = await query(document, "div[data-component=PH_Actions], .gh-header-show .gh-header-actions"); |
127 | 128 |
|
128 | | - if (actions.querySelector(".run-nixpkgs-review") === null) { |
| 129 | + if (actions.querySelector(".run-nixpkgs-review") === null && repo) { |
129 | 130 | const btn = document.createElement("button"); |
130 | 131 | btn.classList.add("Button", "Button--secondary", "Button--small", "run-nixpkgs-review"); |
131 | 132 | btn.innerText = "Run nixpkgs-review"; |
|
0 commit comments