Skip to content

Instantly share code, notes, and snippets.

@michaelb958
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelb958/8949638 to your computer and use it in GitHub Desktop.
Save michaelb958/8949638 to your computer and use it in GitHub Desktop.
"Painfully Obvious Modraters" - Because sometimes (http://meta.stackoverflow.com/q/220442/223030) a diamond just isn't enough.
// ==UserScript==
// @name Painfully Obvious Modraters
// @description For those who can't see diamonds.
// @namespace michaelb958
// @author michaelb958
// @license MIT (http://opensource.org/licenses/MIT)
// @include *://*.stackexchange.com/*
// @include *://*.stackoverflow.com/*
// @include *://*.serverfault.com/*
// @include *://*.superuser.com/*
// @include *://*.stackapps.com/*
// @include *://*.askubuntu.com/*
// @include *://*.mathoverflow.net/*
// ==/UserScript==
function with_jQuery(f) {
var s = document.createElement("script");
s.type = "text/javascript";
s.textContent = "(" + f.toString() + ")(jQuery)";
s.setAttribute('data-with-jquery', '');
document.head.appendChild(s);
};
with_jQuery(function($) {
$('.post-signature:has(.mod-flair)').addClass('obvious-modrater');
$('<style type="text/css">')
.text('.obvious-modrater { border-style: dashed; border-width: 10px; margin: 10px; border-color: transparent; } .obvious-modrater-red { position: absolute; color: white; background-color: red; z-index: 999; font-size: 40px; text-align: center; vertical-align: middle; line-height: 100%; visibility: hidden; }')
.appendTo(document.head);
var counter = -1, interval = setInterval(function() {
try {
counter = (counter + 1) % 16;
var modraters = $('.obvious-modrater'), css = {},
ifodd = function(y, n) { return counter % 2 ? y : n; };
modraters.each(function() {
if ($('.obvious-modrater-red', this).length) return true;
var o = $(this).offset();
$('<div class="obvious-modrater-red">Modrater</div>')
.css({top: o.top, left: o.left,
height: $(this).outerHeight(),
width: $(this).outerWidth()})
.prependTo(this);
});
if (counter < 6) {
css.visibility = '';
css.borderColor = ifodd('', 'red');
} else if (counter < 12) {
css.borderTopColor = css.borderBottomColor = ifodd('', 'red');
css.borderLeftColor = css.borderRightColor = ifodd('red', '');
} else if (counter < 16) {
if (counter == 12) css.borderLeftColor = css.borderRightColor = '';
css.margin = '10px';
css.visibility = 'hidden';
$('.obvious-modrater-red', modraters).css('visibility', ifodd('', 'visible'));
} else {
throw "Counter out of bounds [0,16): bug!";
}
modraters.css(css);
} catch (e) {
clearInterval(interval);
throw e;
}
}, 500);
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment