Skip to content

Commit

Permalink
Fix #35 (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
Katsute authored May 22, 2022
1 parent 43c730a commit 06141a7
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 78 deletions.
115 changes: 37 additions & 78 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (C) 2022 Katsute <https://github.com/Katsute>

"use strict";

const whenElementAdded = (selector, f) => {
const init = setInterval(() => {
const e = document.querySelector(selector);
if(e != null){
f(e);
clearInterval(init);
}
}, 1000 * 1);
}

if(window.location.pathname.toLowerCase().includes("/projects/"))
whenElementAdded(`#__primerPortalRoot__`, (e) => {
e.addEventListener("DOMNodeInserted", (i) => {
if(i.target.tagName && i.target.tagName.toLowerCase() == "svg") // find svg
for(const child of i.target.children) // check svg content
if(child.getAttribute("d") == "M11.28 6.78a.75.75 0 00-1.06-1.06L7.25 8.69 5.78 7.22a.75.75 0 00-1.06 1.06l2 2a.75.75 0 001.06 0l3.5-3.5z") // checkmark
return setTimeout(() => {
i.target.parentElement.classList.add("rissue-closed-bg"); // apply css
}, 100); // doesn't work unless we delay
});
});
1 change: 1 addition & 0 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

"permissions": [],
"content_scripts": [{
"js": ["index.js"],
"css": ["style.css"],
"matches": ["https://github.com/*"]
}]
Expand Down
10 changes: 10 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@ div[data-hovercard-subject-tag^="issue:"] path[d="M16 8A8 8 0 110 8a8 8 0 0116 0
/* pull timeline closed mention label override */
.pull-discussion-timeline .TimelineItem > .TimelineItem-body div[id^="ref-pullrequest-"] ~ div span.State.State--merged {
background-color: var(--rissue-pull-merged) !important;
}

/* js overrides */

.rissue-closed-fg {
color: var(--rissue-issue-closed-fg) !important;
}

.rissue-closed-bg {
background-color: var(--rissue-issue-closed) !important;
}

0 comments on commit 06141a7

Please sign in to comment.