// ==UserScript== // @name Steve's Blocker Script // @version 2.3.3 // @require http://code.jquery.com/jquery-2.0.3.min.js // @include *forum.blockland.us* // @include *blockland.us/smf* // @description Block users and topics. // @author Steve5451 // ==/UserScript== //Known bugs: // none?????? // You can set these variables before deploying the script, but it's not nessisary as you can change the settings in Look and Layout Preferences. var defaultUsersToBlock = "Emo Freak"; //The user(s) you want to be blocked, seperated with a comma without a space. Eg. "Emo Freak,Nal,Steve-senpai" without quotes. var defaultImgMode = false; //True to block JUST their images, false to block their entire post. This can be changed in your Look and Layout Preferences. //-------Other variables that aren't in Look and Layout Preferences.--------\\ var blockTopics = true; //Should a blocked user's topic be blocked? Note: This doesn't apply if you have it set to only block images. var revealText = 'Show garbage'; //The text on the button to show the post / blocked topic. var hideText = 'Hide garbage'; //The text on the button to hide the revealed post / blocked topic. var removeIconURL = 'http://i.imgur.com/txG3bgo.png'; // -------- You should probably leave the below alone ---------\\\ function blockstuffs(item) { if(imgMode == true) { item.find('img').each(function() { if($(this).parent().attr('class') != 'quote') { $(this).before(''); $(this).wrap('
'); } }); } else { item.before(''); item.wrap('
'); } } function blockQuote(item) { if(imgMode == true ) { item.find('img').each(function() { $(this).before(''); $(this).wrap('
'); }); } else { item.wrapInner('
'); item.prepend(''); } } function blockTopic(item) { item.before('' + revealText + ''); item.wrap(''); } function createRemoveButtons() { $('.windowbg2').each(function() { if($(this).children().first().is('img') && $(this).children().first().attr('src') != removeIconURL) { $(this).prepend(''); } }); $('.removeTopic').click(function() { if(localStorage['blockURL'] == undefined) { var newArray = new Array(); localStorage['blockURL'] = JSON.stringify(newArray); } var curURLS = localStorage['blockURL']; var curArray = JSON.parse(curURLS); curArray.push($(this).parent().parent().children().eq(1).children().first().attr('href')); localStorage['blockURL'] = JSON.stringify(curArray); checkTopics(); }); } if(localStorage.blockedUsers2 != undefined) { var blockedUsers = localStorage.blockedUsers2; if(localStorage.imgMode == 'true') { imgMode = true; } else { imgMode = false; } var curName = blockedUsers.split(','); curName.forEach(function(thisName) { if(document.URL.indexOf('?topic=') != -1) { $('.windowbg, .windowbg2').each(function() { var name = $(this).children().children().first().children().first().children().first().children().first().children().first().html(); if(name == thisName) { blockstuffs($(this).find('.post')); } }); $('.quoteheader').each(function() { var name = $(this).children().first().html().split('Quote from: ')[1].split(' on ')[0]; if(name == thisName) { blockQuote($(this).next('.quote')); } }); } else if(document.URL.indexOf('?action=post') != -1) { $('.catbg').each(function() { if($(this).children().first().html() == '\n Posted by: ' + thisName + '\n ') { blockstuffs($(this).next().next().find('.post')); } }); $('.quoteheader').each(function() { var name = $(this).children().first().html().split('Quote from: ')[1].split(' on ')[0]; if(name == thisName) { blockQuote($(this).next('.quote')); } }); } if(document.URL.indexOf('?board=') != -1) { $('.windowbg2').each(function() { var topicCreator = $(this).children().first().html(); if(topicCreator == thisName && imgMode == false && blockTopics == true) { blockTopic($(this).prev().children().first()); } }); } }); $('.togglePost').click(function() { if($(this).attr('revealed') == 'false') { $(this) .attr('revealed', 'true') .val(hideText) .next().css('height', 'auto') .css('width', 'auto'); } else { $(this) .attr('revealed', 'false') .val(revealText) .next().css('height', '0px') .css('width', '0px'); } }); $('.toggleTopic').click(function() { $(this) .next().css('height', 'auto') .css('width', 'auto') $(this).remove(); }); } else { showFirstAlert(); } function showFirstAlert() { if(localStorage.imgMode == false) { var whatsBlocked = "their entire posts"; } else { var whatsBlocked = "just their images"; } $('body').first().append('
Steve\'s Blocker Script
Hi, it appears this is your first time using Steve\'s Blocker Script. Would you like to configure it now? It only takes a second. Otherwise, you will default to "' + defaultUsersToBlock +'" and to block ' + whatsBlocked +'.
You can change your settings later in your Look and Layout Preferences.

Click Yes to be taken to your Look and Layout Preferences, otherwise click No to use the defaults.
'); $('.yesConfigure').click(function() { localStorage.blockedUsers2 = defaultUsersToBlock; localStorage.imgMode = defaultImgMode.toString(); window.location = "http://forum.blockland.us/index.php?action=profile;sa=theme"; }); $('.noConfigure').click(function() { localStorage.blockedUsers2 = defaultUsersToBlock; localStorage.imgMode = defaultImgMode.toString(); $('.stevesAlert').remove(); }); } if(localStorage['blockURL'] == undefined) { var newArray = new Array(); localStorage['blockURL'] = JSON.stringify(newArray); } if(document.URL.indexOf('sa=theme') != -1) { $('input').each(function() { if($(this).val() == 'Change profile') { if(localStorage.imgMode == 'true') { var optionHTML = ''; } else { var optionHTML = ''; } var blockList = ''; var blockArray = JSON.parse(localStorage['blockURL']); if(blockArray.length > 0) { blockList += 'Currently blocked topics:
'; } blockArray.forEach(function(curItem) { blockList += '
' + curItem + '
'; }); $(this).before('

Steve\'s Blocker Script

Blocked users:
Just block images?
Add multiple users with a comma WITHOUT a space between. Eg. \"Emo Freak,Nal,Steve-senpai\" without quotes.
Leave blank to disable (although you could just disable the script)

' + blockList + '
MAKE SURE TO HIT SAVE, CLICKING CHANGE PROFILE WON\'T SAVE THE USER BLOCKER\'S SETTINGS
'); } }); $('.saveUsers').click(function() { localStorage.blockedUsers2 = $('.blockedUsers').val(); localStorage.imgMode = $('.selectImgMode').val(); alert("Saved"); }); } if(localStorage['blockURL'] == undefined) { var newArray = new Array(); localStorage['blockURL'] = JSON.stringify(newArray); } function checkTopics() { $('.windowbg').each(function() { var thisObj = $(this); JSON.parse(localStorage['blockURL']).forEach(function(curItem) { if(thisObj.attr('width') == '42%' && thisObj.children().first().attr('href') == curItem) { thisObj.parent().remove(); } }); }); } checkTopics(); $('.removeFromList').click(function() { var ItemToRemove = $(this).next().html(); var arrayList = JSON.parse(localStorage['blockURL']); var i = arrayList.indexOf(ItemToRemove); arrayList.splice(i,1); localStorage['blockURL'] = JSON.stringify(arrayList); $(this).parent().remove(); }); if(document.URL.indexOf('?board=') != -1) { if(localStorage['showRemButtons'] == 'true') { var remButtonTxt = '-'; } else { var remButtonTxt = '+'; localStorage['showRemButtons'] = 'false'; } $('.titlebg').first().children().first().append('' + remButtonTxt + ''); } else if(document.URL.indexOf('?action=profile;u=') != -1) { var profName = $('.titlebg').first().children().first().html(); curName.forEach(function(cur) { if(profName == '\n ' + cur + '\n ') { $('.titlebg').first().children().first().html(profName + ' (Blocked)'); } }); } if(localStorage['showRemButtons'] == 'true' && document.URL.indexOf('?board=') != -1) { createRemoveButtons(); } $('.plusMinusButton').click(function() { if(localStorage['showRemButtons'] == 'true') { localStorage['showRemButtons'] = 'false'; $(this).html('+'); $('.removeTopic').each(function() { $(this).remove(); }); } else { localStorage['showRemButtons'] = 'true'; $(this).html('-'); createRemoveButtons(); } }); /* Changelog: 1.0 - Initial release 2.0 - Script remade, now a total user blocker. 2.0.1 - Firefox hotfix 2.1 - Now blocks quotes 2.1.1 - Small typo fix, nothing special. 2.2 - Topic blocking 2.3 - Show or hide the topic remover buttons. 2.3.1 - Bug and typo fix. 2.3.2 - Shows that a user is blocked on their profile. 2.3.3 - Blocks posts on the post screen. (Finally!) */