Skip to content

Commit 8997260

Browse files
committed
Some clean up;
1 parent 44c7156 commit 8997260

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

Github_Comment_Enhancer/Github_Comment_Enhancer.user.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@
540540
}
541541

542542
function isGist() {
543-
return location.host === "gist.github.com";
543+
return "gist.github.com" === location.host;
544544
}
545545

546546
function overrideGollumMarkdown() {
@@ -726,6 +726,24 @@
726726
});
727727
}
728728

729+
function addSponsorLink(commentForm){
730+
var tabnavExtras = commentForm.parentNode.parentNode.querySelector(".comment-form-head .tabnav-right, .comment-form-head .right");
731+
if (tabnavExtras) {
732+
var elem = commentForm;
733+
while ((elem = elem.parentNode) && elem.nodeType !== 9 && !elem.classList.contains("timeline-inline-comments")) {}
734+
var sponsoredText = elem !== document ? " Github Comment Enhancer" : " Enhanced by Github Comment Enhancer";
735+
var sponsored = document.createElement("a");
736+
sponsored.setAttribute("target", "_blank");
737+
sponsored.setAttribute("href", "https://github.com/jerone/UserScripts/tree/master/Github_Comment_Enhancer#readme");
738+
sponsored.classList.add("tabnav-widget", "text", "tabnav-extras", "tabnav-extra");
739+
var sponsoredIcon = document.createElement("span");
740+
sponsoredIcon.classList.add("octicon", "octicon-question");
741+
sponsored.appendChild(sponsoredIcon);
742+
sponsored.appendChild(document.createTextNode(sponsoredText));
743+
tabnavExtras.insertBefore(sponsored, tabnavExtras.firstElementChild);
744+
}
745+
}
746+
729747
function commentFormKeyEvent(commentForm, e) {
730748
var keys = [];
731749
if (e.altKey) {
@@ -811,21 +829,7 @@
811829

812830
addCodeSyntax(commentForm);
813831

814-
var tabnavExtras = commentForm.parentNode.parentNode.querySelector(".comment-form-head .tabnav-right, .comment-form-head .right");
815-
if (tabnavExtras) {
816-
var elem = commentForm;
817-
while ((elem = elem.parentNode) && elem.nodeType !== 9 && !elem.classList.contains("timeline-inline-comments")) {}
818-
var sponsoredText = elem !== document ? " Github Comment Enhancer" : " Enhanced by Github Comment Enhancer";
819-
var sponsored = document.createElement("a");
820-
sponsored.setAttribute("target", "_blank");
821-
sponsored.setAttribute("href", "https://github.com/jerone/UserScripts/tree/master/Github_Comment_Enhancer");
822-
sponsored.classList.add("tabnav-widget", "text", "tabnav-extras", "tabnav-extra");
823-
var sponsoredIcon = document.createElement("span");
824-
sponsoredIcon.classList.add("octicon", "octicon-question");
825-
sponsored.appendChild(sponsoredIcon);
826-
sponsored.appendChild(document.createTextNode(sponsoredText));
827-
tabnavExtras.insertBefore(sponsored, tabnavExtras.firstElementChild);
828-
}
832+
addSponsorLink(commentForm);
829833
}
830834

831835
Array.prototype.forEach.call(gollumEditor.parentNode.querySelectorAll(".function-button"), function(button) {

0 commit comments

Comments
 (0)