-
-
Save funkyremi/080f2f84fb275c609484b49b46d146a4 to your computer and use it in GitHub Desktop.
Auto scroll to Github best comment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Auto scroll to Github best comment | |
// Choose one of the following method (Bookmark toolbar link or Browser console) | |
// Minified code (drag and drop to your bookmarks) | |
javascript:var bestCommentId;var bestScore=0;Array.from(document.querySelectorAll(".js-targetable-comment")).forEach(item=>{if(item.querySelector("button.reaction-summary-item")){let commentScore=0;Array.from(item.querySelectorAll("button.reaction-summary-item")).forEach(i=>{if(!!i.innerText){commentScore+=Number(i.innerText.replace(/\D/g,''))}});if(commentScore>bestScore){bestScore=commentScore;bestCommentId=item.id}}});console.log('Comment score',bestScore);location.href=`#${ bestCommentId }`; | |
// Original code (copy paste in your browser console) | |
var bestCommentId; | |
var bestScore = 0; | |
Array.from(document.querySelectorAll(".js-targetable-comment")).forEach(item => { | |
if (item.querySelector("button.reaction-summary-item")) { | |
let commentScore = 0; | |
Array.from(item.querySelectorAll("button.reaction-summary-item")).forEach(i => { | |
if (!!i.innerText) { | |
commentScore += Number(i.innerText.replace(/\D/g, '')); | |
} | |
}); | |
if (commentScore > bestScore) { | |
bestScore = commentScore; | |
bestCommentId = item.id; | |
} | |
} | |
}); | |
console.log('Comment score', bestScore); | |
location.href = `#${bestCommentId}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment