|
540 | 540 | } |
541 | 541 |
|
542 | 542 | function isGist() { |
543 | | - return location.host === "gist.github.com"; |
| 543 | + return "gist.github.com" === location.host; |
544 | 544 | } |
545 | 545 |
|
546 | 546 | function overrideGollumMarkdown() { |
|
726 | 726 | }); |
727 | 727 | } |
728 | 728 |
|
| 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 | + |
729 | 747 | function commentFormKeyEvent(commentForm, e) { |
730 | 748 | var keys = []; |
731 | 749 | if (e.altKey) { |
|
811 | 829 |
|
812 | 830 | addCodeSyntax(commentForm); |
813 | 831 |
|
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); |
829 | 833 | } |
830 | 834 |
|
831 | 835 | Array.prototype.forEach.call(gollumEditor.parentNode.querySelectorAll(".function-button"), function(button) { |
|
0 commit comments