-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub-unread.user.js
More file actions
57 lines (44 loc) · 1.76 KB
/
github-unread.user.js
File metadata and controls
57 lines (44 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// ==UserScript==
// @name GitHub: hide unread
// @version 0.1.4
// @description Hide unread issues and unread pull requests
// @author Muescha
// @namespace https://github.com/muescha
// @match https://github.com/*/*/issues
// @match https://github.com/*/*/issues?*
// @match https://github.com/*/*/pulls
// @match https://github.com/*/*/pulls?*
// @grant none
// @updateURL https://raw.githubusercontent.com/muescha/GitHub-userscripts/master/github-unread.user.js
// @downloadURL https://raw.githubusercontent.com/muescha/GitHub-userscripts/master/github-unread.user.js
// ==/UserScript==
(function () {
'use strict';
function getQueryParts(search) {
return search.split(/\s+/);
}
function includes(search, ...searchStrings) {
return getQueryParts(search).some(queryPart => searchStrings.includes(queryPart));
}
function init() {
let q = document.querySelector("#js-issues-search").value;
const isHideUnread = includes(q, "is:unread");
const isGreyUnread = includes(q, "is:unread-grey", "is:unread-debug", "is:unreadr");
if (isGreyUnread || isHideUnread) {
document.querySelectorAll(".js-navigation-container:first-child div.Box-row:not(.Box-row--unread)").forEach(el => {
if (isHideUnread) {
el.remove();
} else {
let title = el.querySelector("a").innerText
el.classList.add("Box--condensed");
el.querySelector("input").outerHTML = `<div style="width:12px;"></div>`;
let linkEl = el.querySelectorAll("div")[3];
linkEl.innerHTML = title;
linkEl.setAttribute("style", "font-weight: 600!important;color:grey")
}
});
}
}
document.addEventListener("pjax:end", init);
init();
})();