feat: violenmonkey script
This commit is contained in:
parent
99cbcc03d9
commit
1ee19dd0bf
46
scripts/github.js
Normal file
46
scripts/github.js
Normal file
|
@ -0,0 +1,46 @@
|
|||
// ==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');
|
||||
const div = document.createElement('div');
|
||||
div.classList = 'flex-md-order-2 pr_tracker';
|
||||
const pr= window.location.pathname.split('/')[4];
|
||||
|
||||
const btn = document.createElement('button');
|
||||
btn.classList = 'Button--secondary Button--small Button';
|
||||
btn.type = 'button';
|
||||
btn.innerText = `Subscribe`;
|
||||
btn.addEventListener('click', function() {
|
||||
navigator.clipboard.writeText("nim add-pr " + pr);
|
||||
});
|
||||
|
||||
|
||||
div.appendChild(btn);
|
||||
buttonContainerElement.firstElementChild.before(div);
|
||||
}
|
||||
|
||||
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();
|
||||
})();
|
||||
|
Loading…
Reference in a new issue