Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Steve's Blocker Script
- // @version 2.3.C3
- // @updateURL http://pastebin.com/raw.php?i=NKgd5gC6
- // @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) {
- item.before('');
- item.wrap('<div style="width: 0px; height: 0px; overflow: hidden;"></div>');
- }
- function blockTopic(item) {
- item.before('<a style="color: #005177; cursor: pointer;" class="toggleTopic" revealed="false">' + revealText + '</a>');
- item.wrap('<span style="width: 0px; height: 0px; display: inline-block; overflow: hidden;"></span>');
- }
- function createRemoveButtons() {
- $('.windowbg2').each(function() {
- if($(this).children().first().is('img') && $(this).children().first().attr('src') != removeIconURL) {
- $(this).prepend('<img class="removeTopic" style="cursor: pointer;" src="' + removeIconURL + '" />');
- }
- });
- $('.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) {
- $(this).remove();
- }
- });
- $('.quoteheader').each(function() {
- var name = $(this).children().first().html().split('Quote from: ')[1].split(' on ')[0];
- if(name == thisName) {
- $(this).next().remove();
- $(this).remove();
- }
- });
- } else if(document.URL.indexOf('?action=post') != -1) {
- $('.catbg').each(function() {
- if($(this).children().first().html() == '\n Posted by: ' + thisName + '\n ') {
- //dont know how to get this to delete, so i'm leaving it empty
- }
- });
- $('.quoteheader').each(function() {
- var name = $(this).children().first().html().split('Quote from: ')[1].split(' on ')[0];
- if(name == thisName) {
- $(this).next().remove();
- $(this).remove();
- }
- });
- }
- 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('<div class="stevesAlert" style="position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; background-color: rgba(0,0,0,0.5);"><div class="firstAlert" style="margin: 0 auto; width: 550px; border: 1px solid #555; background-color: #fff; box-shadow: 0px 1px 5px #333; margin-top: 100px; color: #333;"><div style="background-color: #6e94b7; font-size: 16pt; text-align: center; padding-top: 3px; padding-bottom: 3px; border-bottom: 1px solid #000; color: #fff;">Steve\'s Blocker Script</div><div style="padding: 10px;">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 +'.<br/>You can change your settings later in your Look and Layout Preferences.<br/><br/>Click Yes to be taken to your Look and Layout Preferences, otherwise click No to use the defaults.<br/><div style="margin: 0 auto; width: 100px;"><input type="button" class="yesConfigure" value="Yes" stlye="float: left;"/><input type="button" class="noConfigure" value="No" style="float: right;" /></div></div></div></div>');
- $('.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 = '<option value="true">True</option><option value="false">False</option>';
- } else {
- var optionHTML = '<option value="false">False</option><option value="true">True</option>';
- }
- var blockList = '';
- var blockArray = JSON.parse(localStorage['blockURL']);
- if(blockArray.length > 0) {
- blockList += 'Currently blocked topics:<br/>';
- }
- blockArray.forEach(function(curItem) {
- blockList += '<div><img style="cursor: pointer;" class="removeFromList" src="' + removeIconURL + '" /> <a target="_blank" href="' + curItem + '">' + curItem + '</a></div>';
- });
- $(this).before('<div align="left"><h4>Steve\'s Blocker Script</h4>Blocked users: <input style="width: 300px;" class="blockedUsers" value="' + localStorage.blockedUsers2 + '" /><br/>Just block images? <select class="selectImgMode">' + optionHTML + '</select><input type="button" class="saveUsers" value="Save" /><br/><div style="font-size: 8pt;">Add multiple users with a comma WITHOUT a space between. Eg. \"Emo Freak,Nal,Steve-senpai\" without quotes.<br/>Leave blank to disable (although you could just disable the script)</div><br/>' + blockList + '<td colspan="2"><hr width="100%" size="1" class="hrcolor">MAKE SURE TO HIT SAVE, CLICKING CHANGE PROFILE WON\'T SAVE THE USER BLOCKER\'S SETTINGS</td><br/></div>');
- }
- });
- $('.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('<a class="plusMinusButton" style="cursor: pointer;">' + remButtonTxt + '</a>');
- } 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 + ' <a style="text-decoration: none; font-weight: normal;">(Blocked)<a>');
- }
- });
- }
- 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!)
- 2.3.C - Deletes their post (crispy's edit)
- 2.3.C2 - Does not block quotes (crispy's edit)
- 2.3.C2 - Deletes quotes (crispy's edit)
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement