2024-12-30 13:55:15 +01:00
|
|
|
// ==UserScript==
|
|
|
|
// @name Nixpkgs subscribe
|
|
|
|
// @namespace http://tampermonkey.net/
|
|
|
|
// @version 2024-07-25
|
|
|
|
// @description try to take over the world!
|
|
|
|
// @author You
|
|
|
|
// @match https://github.com/*
|
|
|
|
// @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
|
|
|
|
// ==/UserScript==
|
|
|
|
|
|
|
|
|
|
|
|
function addButton() {
|
|
|
|
const buttonContainerElement = document.querySelector('.gh-header-actions');
|
2025-01-02 13:39:52 +01:00
|
|
|
const pr= window.location.pathname.split('/')[4];
|
|
|
|
|
2024-12-30 13:55:15 +01:00
|
|
|
const div = document.createElement('div');
|
|
|
|
div.classList = 'flex-md-order-2 pr_tracker';
|
|
|
|
|
|
|
|
const btn = document.createElement('button');
|
|
|
|
btn.classList = 'Button--secondary Button--small Button';
|
|
|
|
btn.type = 'button';
|
2025-01-02 13:39:52 +01:00
|
|
|
btn.innerText = `nim add`;
|
2024-12-30 13:55:15 +01:00
|
|
|
btn.addEventListener('click', function() {
|
|
|
|
navigator.clipboard.writeText("nim add-pr " + pr);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
div.appendChild(btn);
|
|
|
|
buttonContainerElement.firstElementChild.before(div);
|
2025-01-02 13:39:52 +01:00
|
|
|
|
|
|
|
const div2 = document.createElement('div');
|
|
|
|
div2.classList = 'flex-md-order-2 pr_tracker';
|
|
|
|
|
|
|
|
const btn2 = document.createElement('button');
|
|
|
|
btn2.classList = 'Button--secondary Button--small Button';
|
|
|
|
btn2.type = 'button';
|
|
|
|
btn2.innerText = `nixpkgs-review`;
|
|
|
|
btn2.addEventListener('click', function() {
|
|
|
|
navigator.clipboard.writeText("nixpkgs-review pr " + pr);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
div2.appendChild(btn2);
|
|
|
|
buttonContainerElement.firstElementChild.before(div2);
|
2024-12-30 13:55:15 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function maybeAddButton(){
|
|
|
|
const loc = window.location.pathname;
|
|
|
|
if (loc.match("^/NixOS/nixpkgs/pull/[0-9]*") && (document.getElementsByClassName("pr_tracker").length == 0 )){
|
|
|
|
addButton();
|
|
|
|
}
|
|
|
|
setTimeout(maybeAddButton, 250);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
(function() {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// Your code here...
|
|
|
|
maybeAddButton();
|
|
|
|
})();
|
|
|
|
|