paradocks

BlabBlock v.1

Feb 22nd, 2016
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         BlabBlock v.1
  3. // @version      0.1
  4. // @description  fuck the wurld
  5. // @author       @paradoxal420
  6. // @match        https://blab.im/*
  7. // @grant        none
  8. // ==/UserScript==
  9.  
  10. 'use strict';
  11. $(function() {
  12.  
  13.     if (!localStorage.blockList)
  14.     {
  15.         localStorage.blockList = JSON.stringify([]);
  16.     }
  17.  
  18.     var ignoreUser = function(usr)
  19.     {
  20.         var newList = JSON.parse(localStorage.blockList);
  21.         if (localStorage.blockList.indexOf(usr) == -1)
  22.         {
  23.             newList.push(usr);
  24.             console.info(usr + ' - added to blocklist');
  25.             localStorage.blockList = JSON.stringify(newList);
  26.         }
  27.         else
  28.         {
  29.             console.error('User Exists'); // Shouldn't be triggered anyways
  30.         }
  31.     }
  32.    
  33.     if (window.ignoreUser == undefined)
  34.     {
  35.         window.ignoreUser = ignoreUser;
  36.     }
  37.  
  38.     function genIgnoreButton() {
  39.         $('li.chat-message a.username span:last-child').css('font-size', '14px');
  40.         if ($('li.chat-message a.username span:last-child'))
  41.         {
  42.             var users = $('li.chat-message a.username span:last-child')
  43.             , index = 0;
  44.             while (index < users.length - 1)
  45.             {
  46.                 index++;
  47.                 if (users[index].parentElement.parentElement.innerHTML.substr(0, 5) != '<butt')
  48.                 {
  49.                     users[index].parentElement.parentElement.innerHTML = '<button onclick="ignoreUser(\'' + users[index].innerText + '\')" style="opacity:0.5;font-size: 8px;">I</button> ' + users[index].parentElement.parentElement.innerHTML;
  50.                 }
  51.  
  52.             }
  53.         }
  54.     }
  55.  
  56.     setInterval(genIgnoreButton, 200);
  57.  
  58.     function deleteMessages()
  59.     {
  60.         if (localStorage.blockList)
  61.         {
  62.             var usernames = JSON.parse(localStorage.blockList);
  63.             for (var i = 0; i < usernames.length; i++)
  64.             {
  65.                 $('span:contains("' + usernames[i] + '")').parent().parent().parent().parent().parent().remove();
  66.             }
  67.         }
  68.  
  69.     }
  70.     setInterval(deleteMessages, 200);
  71. });
Advertisement
Add Comment
Please, Sign In to add comment