Advertisement
Guest User

black list avn

a guest
Nov 7th, 2017
2,876
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Blacklist Avn
  3. // @namespace    https://avenoel.org/forum
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       You
  7. // @match        https://avenoel.org/*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12.     'use strict';
  13.  
  14.  
  15.     let blacklist;
  16.     if (localStorage.getItem('blacklist') === null) {
  17.         blacklist = {};
  18.         console.log('blacklist vide');
  19.     } else {
  20.         blacklist = JSON.parse(localStorage.getItem('blacklist'));
  21.         console.log(blacklist);
  22.     }
  23.    
  24.     let clearBL = document.createElement('li');
  25.     let a = document.createElement('a');
  26.  
  27.     a.href = '#';
  28.     a.innerText = 'Clear BL';
  29.     clearBL.addEventListener('click', event => {
  30.         localStorage.setItem('blacklist', JSON.stringify({}));
  31.         document.location.reload();
  32.     });
  33.     clearBL.appendChild(a);
  34.                              
  35.     document.getElementsByClassName('aside')[0].getElementsByTagName('ul')[0].appendChild(clearBL);
  36.    
  37.     Array.from(document.getElementsByClassName('message-actions')).map(x => {
  38.         let li = document.createElement('li');
  39.         let a = document.createElement('a');
  40.         let img = document.createElement('img');
  41.  
  42.         img.src = 'https://avenoel.org/images/topic/ban.png';
  43.         a.href = '#';
  44.         a.appendChild(img);
  45.         a.addEventListener('click', event => {
  46.             let blacklist;
  47.             if (localStorage.getItem('blacklist') === null) {
  48.                 blacklist = {};
  49.             } else {
  50.                 blacklist = JSON.parse(localStorage.getItem('blacklist'));
  51.             }
  52.            
  53.             blacklist[event.target.parentNode.parentNode.parentNode.parentNode.getElementsByClassName('message-username')[0].innerText.toLowerCase()] = true;
  54.             localStorage.blacklist = JSON.stringify(blacklist);
  55.             console.log(event.target.parentNode.parentNode.parentNode.parentNode.getElementsByClassName('message-username')[0].innerText.toLowerCase()+" blacklisté");
  56.             document.location.reload();
  57.         });
  58.         li.appendChild(a);
  59.         x.appendChild(li);
  60.     });
  61.  
  62.     console.log('ok');
  63.     Array.from(document.getElementsByClassName('topics-author')).slice(1).filter(x => blacklist[x.getElementsByTagName('a')[0].innerText.toLowerCase()] === true).map(x => x.parentNode.remove());
  64.     Array.from(document.getElementsByClassName('message-username')).filter(x => blacklist[x.getElementsByTagName('a')[0].innerText.toLowerCase()] === true).map(x => x.parentNode.parentNode.parentNode.remove());
  65.  
  66. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement