Advertisement
Guest User

2.3.C3

a guest
Jan 27th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.02 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Steve's Blocker Script
  3. // @version 2.3.C3
  4. // @updateURL http://pastebin.com/raw.php?i=NKgd5gC6
  5. // @require http://code.jquery.com/jquery-2.0.3.min.js
  6. // @include *forum.blockland.us*
  7. // @include *blockland.us/smf*
  8. // @description Block users and topics.
  9. // @author Steve5451
  10. // ==/UserScript==
  11. //Known bugs:
  12. // none??????
  13.  
  14. // 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.
  15.  
  16. 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.
  17. 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.
  18.  
  19. //-------Other variables that aren't in Look and Layout Preferences.--------\\
  20.  
  21. 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.
  22.  
  23. var revealText = 'Show garbage'; //The text on the button to show the post / blocked topic.
  24. var hideText = 'Hide garbage'; //The text on the button to hide the revealed post / blocked topic.
  25.  
  26. var removeIconURL = 'http://i.imgur.com/txG3bgo.png';
  27.  
  28. // -------- You should probably leave the below alone ---------\\\
  29.  
  30. function blockstuffs(item) {
  31. item.before('');
  32. item.wrap('<div style="width: 0px; height: 0px; overflow: hidden;"></div>');
  33. }
  34.  
  35. function blockTopic(item) {
  36. item.before('<a style="color: #005177; cursor: pointer;" class="toggleTopic" revealed="false">' + revealText + '</a>');
  37. item.wrap('<span style="width: 0px; height: 0px; display: inline-block; overflow: hidden;"></span>');
  38. }
  39.  
  40. function createRemoveButtons() {
  41. $('.windowbg2').each(function() {
  42. if($(this).children().first().is('img') && $(this).children().first().attr('src') != removeIconURL) {
  43. $(this).prepend('<img class="removeTopic" style="cursor: pointer;" src="' + removeIconURL + '" />');
  44. }
  45. });
  46.  
  47. $('.removeTopic').click(function() {
  48. if(localStorage['blockURL'] == undefined) {
  49. var newArray = new Array();
  50. localStorage['blockURL'] = JSON.stringify(newArray);
  51. }
  52. var curURLS = localStorage['blockURL'];
  53. var curArray = JSON.parse(curURLS);
  54. curArray.push($(this).parent().parent().children().eq(1).children().first().attr('href'));
  55. localStorage['blockURL'] = JSON.stringify(curArray);
  56. checkTopics();
  57. });
  58. }
  59.  
  60. if(localStorage.blockedUsers2 != undefined) {
  61. var blockedUsers = localStorage.blockedUsers2;
  62. if(localStorage.imgMode == 'true') {
  63. imgMode = true;
  64. } else {
  65. imgMode = false;
  66. }
  67. var curName = blockedUsers.split(',');
  68.  
  69. curName.forEach(function(thisName) {
  70. if(document.URL.indexOf('?topic=') != -1) {
  71. $('.windowbg, .windowbg2').each(function() {
  72. var name = $(this).children().children().first().children().first().children().first().children().first().children().first().html();
  73. if(name == thisName) {
  74. $(this).remove();
  75. }
  76. });
  77. $('.quoteheader').each(function() {
  78. var name = $(this).children().first().html().split('Quote from: ')[1].split(' on ')[0];
  79. if(name == thisName) {
  80. $(this).next().remove();
  81. $(this).remove();
  82. }
  83. });
  84. } else if(document.URL.indexOf('?action=post') != -1) {
  85. $('.catbg').each(function() {
  86. if($(this).children().first().html() == '\n Posted by: ' + thisName + '\n ') {
  87. //dont know how to get this to delete, so i'm leaving it empty
  88. }
  89. });
  90. $('.quoteheader').each(function() {
  91. var name = $(this).children().first().html().split('Quote from: ')[1].split(' on ')[0];
  92. if(name == thisName) {
  93. $(this).next().remove();
  94. $(this).remove();
  95. }
  96. });
  97. }
  98.  
  99. if(document.URL.indexOf('?board=') != -1) {
  100. $('.windowbg2').each(function() {
  101. var topicCreator = $(this).children().first().html();
  102. if(topicCreator == thisName && imgMode == false && blockTopics == true) {
  103. blockTopic($(this).prev().children().first());
  104. }
  105. });
  106. }
  107. });
  108.  
  109. $('.togglePost').click(function() {
  110. if($(this).attr('revealed') == 'false') {
  111. $(this)
  112. .attr('revealed', 'true')
  113. .val(hideText)
  114. .next().css('height', 'auto')
  115. .css('width', 'auto');
  116. } else {
  117. $(this)
  118. .attr('revealed', 'false')
  119. .val(revealText)
  120. .next().css('height', '0px')
  121. .css('width', '0px');
  122. }
  123. });
  124.  
  125. $('.toggleTopic').click(function() {
  126. $(this)
  127. .next().css('height', 'auto')
  128. .css('width', 'auto')
  129. $(this).remove();
  130. });
  131.  
  132. } else {
  133. showFirstAlert();
  134. }
  135.  
  136. function showFirstAlert() {
  137. if(localStorage.imgMode == false) {
  138. var whatsBlocked = "their entire posts";
  139. } else {
  140. var whatsBlocked = "just their images";
  141. }
  142. $('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>');
  143.  
  144. $('.yesConfigure').click(function() {
  145. localStorage.blockedUsers2 = defaultUsersToBlock;
  146. localStorage.imgMode = defaultImgMode.toString();
  147. window.location = "http://forum.blockland.us/index.php?action=profile;sa=theme";
  148. });
  149. $('.noConfigure').click(function() {
  150. localStorage.blockedUsers2 = defaultUsersToBlock;
  151. localStorage.imgMode = defaultImgMode.toString();
  152. $('.stevesAlert').remove();
  153. });
  154. }
  155.  
  156. if(localStorage['blockURL'] == undefined) {
  157. var newArray = new Array();
  158. localStorage['blockURL'] = JSON.stringify(newArray);
  159. }
  160.  
  161. if(document.URL.indexOf('sa=theme') != -1) {
  162. $('input').each(function() {
  163. if($(this).val() == 'Change profile') {
  164. if(localStorage.imgMode == 'true') {
  165. var optionHTML = '<option value="true">True</option><option value="false">False</option>';
  166. } else {
  167. var optionHTML = '<option value="false">False</option><option value="true">True</option>';
  168. }
  169. var blockList = '';
  170. var blockArray = JSON.parse(localStorage['blockURL']);
  171. if(blockArray.length > 0) {
  172. blockList += 'Currently blocked topics:<br/>';
  173. }
  174. blockArray.forEach(function(curItem) {
  175. blockList += '<div><img style="cursor: pointer;" class="removeFromList" src="' + removeIconURL + '" /> <a target="_blank" href="' + curItem + '">' + curItem + '</a></div>';
  176. });
  177. $(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>');
  178. }
  179. });
  180.  
  181. $('.saveUsers').click(function() {
  182. localStorage.blockedUsers2 = $('.blockedUsers').val();
  183. localStorage.imgMode = $('.selectImgMode').val();
  184. alert("Saved");
  185. });
  186. }
  187.  
  188. if(localStorage['blockURL'] == undefined) {
  189. var newArray = new Array();
  190. localStorage['blockURL'] = JSON.stringify(newArray);
  191. }
  192.  
  193. function checkTopics() {
  194. $('.windowbg').each(function() {
  195. var thisObj = $(this);
  196. JSON.parse(localStorage['blockURL']).forEach(function(curItem) {
  197. if(thisObj.attr('width') == '42%' && thisObj.children().first().attr('href') == curItem) {
  198. thisObj.parent().remove();
  199. }
  200. });
  201. });
  202. }
  203.  
  204. checkTopics();
  205.  
  206. $('.removeFromList').click(function() {
  207. var ItemToRemove = $(this).next().html();
  208. var arrayList = JSON.parse(localStorage['blockURL']);
  209. var i = arrayList.indexOf(ItemToRemove);
  210. arrayList.splice(i,1);
  211. localStorage['blockURL'] = JSON.stringify(arrayList);
  212. $(this).parent().remove();
  213. });
  214.  
  215. if(document.URL.indexOf('?board=') != -1) {
  216. if(localStorage['showRemButtons'] == 'true') {
  217. var remButtonTxt = '-';
  218. } else {
  219. var remButtonTxt = '+';
  220. localStorage['showRemButtons'] = 'false';
  221. }
  222. $('.titlebg').first().children().first().append('<a class="plusMinusButton" style="cursor: pointer;">' + remButtonTxt + '</a>');
  223. } else if(document.URL.indexOf('?action=profile;u=') != -1) {
  224. var profName = $('.titlebg').first().children().first().html();
  225. curName.forEach(function(cur) {
  226. if(profName == '\n ' + cur + '\n ') {
  227. $('.titlebg').first().children().first().html(profName + ' <a style="text-decoration: none; font-weight: normal;">(Blocked)<a>');
  228. }
  229. });
  230.  
  231. }
  232.  
  233. if(localStorage['showRemButtons'] == 'true' && document.URL.indexOf('?board=') != -1) {
  234. createRemoveButtons();
  235. }
  236.  
  237. $('.plusMinusButton').click(function() {
  238. if(localStorage['showRemButtons'] == 'true') {
  239. localStorage['showRemButtons'] = 'false';
  240. $(this).html('+');
  241. $('.removeTopic').each(function() {
  242. $(this).remove();
  243. });
  244. } else {
  245. localStorage['showRemButtons'] = 'true';
  246. $(this).html('-');
  247. createRemoveButtons();
  248. }
  249. });
  250.  
  251. /*
  252. Changelog:
  253. 1.0 - Initial release
  254. 2.0 - Script remade, now a total user blocker.
  255. 2.0.1 - Firefox hotfix
  256. 2.1 - Now blocks quotes
  257. 2.1.1 - Small typo fix, nothing special.
  258. 2.2 - Topic blocking
  259. 2.3 - Show or hide the topic remover buttons.
  260. 2.3.1 - Bug and typo fix.
  261. 2.3.2 - Shows that a user is blocked on their profile.
  262. 2.3.3 - Blocks posts on the post screen. (Finally!)
  263. 2.3.C - Deletes their post (crispy's edit)
  264. 2.3.C2 - Does not block quotes (crispy's edit)
  265. 2.3.C2 - Deletes quotes (crispy's edit)
  266. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement