Advertisement
Guest User

Antilizar US

a guest
May 25th, 2015
948
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Antilizar
  3. // @version     0.1
  4. // @description Убрать посты от определенных авторов
  5. // @author      x0wl
  6. // @grant       none
  7. // @include     http*://*geektimes.ru/*
  8. // @include     http*://*habrahabr.ru/*
  9. // @exclude     http*://*geektimes.ru/post/*
  10. // @exclude     http*://*habrahabr.ru/post/*
  11. // ==/UserScript==
  12.  
  13. //BEGIN SETTINGS
  14. var bad_authors = ["SLY_G", "alizar"];  //Расстрельный список
  15. var color = true; //false - просто скрывать, true - подсвечивать
  16. var hcolor = "#ff9baa"; //Цвет подсветки
  17. //END SETTINGS
  18.  
  19. Array.prototype.contains = function(obj) {
  20.     var i = this.length;
  21.     while (i--) {
  22.         if (this[i] === obj) {
  23.             return true;
  24.         }
  25.     }
  26.     return false;
  27. } //Взято с https://stackoverflow.com/questions/237104/array-containsobj-in-javascript
  28.  
  29. var posts = document.getElementsByClassName("post shortcuts_item")  //Получаем все посты
  30.  
  31. for(var i = 0; i < posts.length; i++){
  32.     var post = posts[i];
  33.     var author = post.getElementsByClassName("infopanel_wrapper")[0].getElementsByClassName("infopanel")[0].getElementsByClassName("author")[0].getElementsByTagName("a")[0].innerHTML; //Получаем имя автора
  34.     if(bad_authors.contains(author)){
  35.         if(color){
  36.             post.style.backgroundColor = hcolor; //Подсвечиваем
  37.         }
  38.         else{
  39.             post.style.display = "none"; //Скрываем
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement