Skip to content

Commit a93ecaa

Browse files
committed
feat: Added a range of useful Github userscripts ive built so far
1 parent 6b0af9f commit a93ecaa

6 files changed

+168
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// ==UserScript==
2+
// @name GitHub projects - Decrease column widths
3+
// @namespace https://www.wildfireinternet.co.uk/
4+
// @version 0.1
5+
// @description By default the column widths on project boards on github are too big, this decreases them a little
6+
// @author Andrew
7+
// @match https://github.com/*/*/projects/*
8+
// @grant none
9+
// ==/UserScript==
10+
11+
(function() {
12+
'use strict';
13+
14+
var style = document.createElement('style');
15+
style.innerHTML = '.project-column { max-width: 300px; min-width: 300px; }';
16+
document.body.appendChild(style);
17+
18+
})();
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// ==UserScript==
2+
// @name GitHub projects - WIP limit / column red
3+
// @namespace https://www.wildfireinternet.co.uk/
4+
// @version 0.1
5+
// @description Glow "in progress" column red when WIP limit reached
6+
// @author Andrew
7+
// @match https://github.com/orgs/WildfireInternet/projects/1*
8+
// @grant none
9+
// ==/UserScript==
10+
11+
(function() {
12+
'use strict';
13+
14+
var wipLimit = 2;
15+
var wipColumId = 2785096;
16+
17+
var inProgressCol = document.querySelector('#column-' + wipColumId);
18+
var counterEl = inProgressCol.querySelector('.Counter');
19+
20+
function checkWIPLimit() {
21+
22+
var count = counterEl.innerText;
23+
inProgressCol.style.background = count > wipLimit ? 'lightcoral' : '';
24+
25+
}
26+
27+
checkWIPLimit();
28+
counterEl.addEventListener('DOMSubtreeModified', checkWIPLimit, false);
29+
30+
})();
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
// ==UserScript==
2+
// @name GitHub projects - focus on clicked card
3+
// @namespace https://www.wildfireinternet.co.uk/
4+
// @version 0.1
5+
// @description focuses out the rest of the page when a cards sidebar info is showing
6+
// @author Andrew
7+
// @match https://github.com/*/*/projects/*
8+
// @grant none
9+
// ==/UserScript==
10+
11+
(function() {
12+
'use strict';
13+
14+
// fade opacity of other content like a modal
15+
var style = document.createElement('style');
16+
style.innerHTML = '.hide-sm ~ .project-columns { opacity: .5; }';
17+
style.innerHTML += ' .js-project-card-details-pane { width: 560px !important; }';
18+
document.body.appendChild(style);
19+
20+
// helper to simulate click
21+
function clickEl(el) {
22+
var event = document.createEvent('HTMLEvents');
23+
event.initEvent('click', true, false);
24+
el.dispatchEvent(event);
25+
}
26+
27+
// delay helper, setTimeout but sweeter promise syntax ;)
28+
function delay(seconds) {
29+
let promise = new Promise(resolve => setTimeout(resolve, seconds));
30+
return promise;
31+
}
32+
33+
// helper to close card info
34+
function closeCardInfo() {
35+
var el = document.querySelector('.js-project-card-details .js-hide-project-card-details');
36+
if (el && el.offsetParent) {
37+
delay(500).then(() => clickEl(el));
38+
}
39+
}
40+
41+
// bind ESC to close card info
42+
document.body.addEventListener('keydown', (event) => {
43+
if (event.key == 'Escape' || event.key == 'Esc') {
44+
closeCardInfo();
45+
}
46+
});
47+
48+
// also bind click to close card info
49+
// ~~~~~~
50+
// TODO: revisit this, i'm not happy that it's bound to EVERY click atm, not the most performant way of doing this!
51+
// ~~~~~~
52+
document.body.addEventListener('click', (event) => {
53+
var els = document.querySelectorAll('.hide-sm ~ .project-columns');
54+
if (els && els.length && els[0].contains(event.target)) {
55+
closeCardInfo();
56+
}
57+
});
58+
59+
})();
60+
61+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// ==UserScript==
2+
// @name GitHub projects - highlight my user
3+
// @namespace https://www.wildfireinternet.co.uk/
4+
// @version 0.1
5+
// @description background colour change for my user's tasks ;D
6+
// @author Andrew
7+
// @match https://github.com/*/*/projects/*
8+
// @grant none
9+
// ==/UserScript==
10+
11+
(function() {
12+
'use strict';
13+
14+
var style = document.createElement('style');
15+
style.innerHTML = 'div[data-card-assignee="\\[\\"stilliard\\"\\]"] { background-color: #e3f9d4 !important; }';
16+
document.body.appendChild(style);
17+
18+
})();
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// ==UserScript==
2+
// @name GitHub projects - more emphasis on repo name
3+
// @namespace https://www.wildfireinternet.co.uk/
4+
// @version 0.1
5+
// @description repo names are tiny by default and shows the opener of the issue but that's not of much use so we remove it and replace with a bigger bolder repo name
6+
// @author Andrew
7+
// @match https://github.com/*/*/projects/*
8+
// @grant none
9+
// ==/UserScript==
10+
11+
(function() {
12+
'use strict';
13+
14+
var style = document.createElement('style');
15+
style.innerHTML = '.js-project-issue-details-container .text-gray.d-block { font-size: 14px; font-weight: bold; font-family: monospace; overflow: hidden; height: 25px; position: absolute; top: 6px; }'; // font improvements & move to top
16+
style.innerHTML += ' .js-project-card-issue-link { margin-top: 23px; }'; // push down under the repo name now positioned to the top
17+
style.innerHTML += ' .js-issue-number { font-weight: normal; }';
18+
style.innerHTML += ' .js-issue-number:after { content: ""; display: block; }'; // hide added by area by pushing it out of view
19+
style.innerHTML += ' [data-card-type=\'\["note"\]\'] small.text-gray-light { display:none; }'; // also hide note added by line
20+
document.body.appendChild(style);
21+
22+
})();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// ==UserScript==
2+
// @name GitHub projects - reload if internet connection drops and then has reconnected
3+
// @namespace https://www.wildfireinternet.co.uk/
4+
// @version 0.1
5+
// @description Atm if it drops and comes back the websocket connections die
6+
// @author Andrew
7+
// @match https://github.com/*/*/projects/*
8+
// @grant none
9+
// ==/UserScript==
10+
11+
(function() {
12+
'use strict';
13+
14+
window.addEventListener('online', function () {
15+
console.log('Connection lost but is now back, reloading page to bring back websockets!');
16+
window.location.reload();
17+
});
18+
19+
})();

0 commit comments

Comments
 (0)