Skip to content

Instantly share code, notes, and snippets.

@timhobbs
Last active December 15, 2015 02:49
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 timhobbs/5190423 to your computer and use it in GitHub Desktop.
Save timhobbs/5190423 to your computer and use it in GitHub Desktop.
Trolliminator! eliminates troll posts from Gigya comments. Simply add a comma-separated list of troll usernames to the trolls variable at the top, then save this js snippet as a bookmark. Whenever you want to trolliminate posts, just click the bookmark! All troll posts will be marked with a "Trolliminated!" string and a total count will be displ…
javascript: (function () {
var trolls = [
'troll', // <-- add troll names here
];
var el = document.createElement('div'),
b = document.getElementsByTagName('body')[0];
otherlib = false, msg = '';
el.style.position = 'fixed';
el.style.height = '32px';
el.style.width = '220px';
el.style.marginLeft = '-110px';
el.style.top = '0';
el.style.left = '50%';
el.style.padding = '5px 10px 5px 10px';
el.style.zIndex = 1001;
el.style.fontSize = '12px';
el.style.color = '#222';
el.style.backgroundColor = '#f99';
if (typeof jQuery != 'undefined') {
msg = 'This page already using jQuery v' + jQuery.fn.jquery;
return showMsg();
} else if (typeof $ == 'function') {
otherlib = true;
}
function getScript(url, success) {
var script = document.createElement('script');
script.src = url;
var head = document.getElementsByTagName('head')[0],
done = false;
script.onload = script.onreadystatechange = function () {
if (!done && (!this.readyState || this.readyState == 'loaded' || this.readyState == 'complete')) {
done = true;
success();
}
};
head.appendChild(script);
}
getScript('http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js', function () {
if (typeof jQuery == 'undefined') {
msg = 'Sorry, but jQuery wasn\'t able to load';
} else {
msg = 'This page is now jQuerified with v' + jQuery.fn.jquery;
if (otherlib) {
msg += ' and noConflict(). Use $jq(), not $().';
}
}
return showMsg();
});
function showMsg() {
el.innerHTML = msg;
b.appendChild(el);
window.setTimeout(function () {
if (typeof jQuery == 'undefined') {
b.removeChild(el);
} else {
jQuery(el).fadeOut('slow', function () {
jQuery(this).remove();
});
if (otherlib) {
$jq = jQuery.noConflict();
}
trolliminator();
}
}, 2500);
}
function trolliminator() {
var $ = jQuery;
var matchCounter = 0;
$.each(trolls, function(index, value) {
$('.gig-comments-comment-username').filter(function() {
var match = $(this).text() == value;
if (match) {
var table = $(this).closest('table');
table.hide();
table.parent().append($('<div>').css({ 'color':'#666', 'font-style':'italic' }).html('Trolliminated!'));
matchCounter++;
return match;
}
});
});
$('<div>').css({ 'position':'fixed', 'right':'0', 'bottom':'0', 'padding':'5px', 'font-weight':'bold', 'color':'#090', 'z-index':'99999' }).html(matchCounter + ' trolls eliminated').appendTo('body');
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment