Skip to content

Instantly share code, notes, and snippets.

@shu8
Created May 20, 2016 21:33
Show Gist options
  • Save shu8/a6ea1b1b9bcd12065ff8da997a1f7686 to your computer and use it in GitHub Desktop.
Save shu8/a6ea1b1b9bcd12065ff8da997a1f7686 to your computer and use it in GitHub Desktop.
A userscript that adds a darker border underneath comments if there are some hidden after it
// ==UserScript==
// @name Hidden comment indicator
// @namespace http://stackexchange.com/users/4337810/
// @version 1.0
// @description A userscript that adds a darker border underneath comments if there are some hidden after it
// @author ᔕᖺᘎᕊ (http://stackexchange.com/users/4337810/)
// @match *://*.stackexchange.com/questions/*
// @match *://*.stackoverflow.com/questions/*
// @match *://*.superuser.com/questions/*
// @match *://*.serverfault.com/questions/*
// @match *://*.askubuntu.com/questions/*
// @match *://*.stackapps.com/questions/*
// @match *://*.mathoverflow.net/questions/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
$('.question, .answer').each(function() {
if($(this).find('.js-show-link.comments-link:visible').length) {
var postId = $(this).attr('data-questionid') || $(this).attr('data-answerid'),
x=[],
y=[],
protocol = location.protocol,
hostname = location.hostname,
baseUrl = protocol + '//' + hostname;
$.get(baseUrl + '/posts/' + postId + '/comments', function(d) {
var $commentCopy = $('#comments-' + postId + ' .comment-text .comment-copy');
$(d).find('.comment-text').each(function(i) {
x.push($(this).find('.comment-copy').text());
});
$commentCopy.filter(function(d) {
y.push(x.indexOf($commentCopy.eq(d).text()));
});
for(var i=0;i<y.length;i++){
if(y[i] != y[i+1]-1) {
$commentCopy.filter(function(d) {
return $(this).text() == x[y[i]];
}).parent().parent().parent().find('.comment-actions, .comment-text').css('border-bottom-color', 'gray');
}
}
});
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment