Advertisement
Guest User

Untitled

a guest
Sep 18th, 2018
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. // ==UserScript==
  2. // @name WykopCrapFilter
  3. // @version 1
  4. // @grant Melcma
  5. // ==/UserScript==
  6.  
  7. // config
  8.  
  9. // types: warning/accepted/banned
  10. var markedUrls = [
  11. {
  12. url: 'wp.pl',
  13. type: 'warning'
  14. },
  15. {
  16. url: 'liveleak.com',
  17. type: 'accepted'
  18. },
  19. {
  20. url: 'youtube.com',
  21. type: 'accepted'
  22. },
  23. {
  24. url: 'youtu.be',
  25. type: 'accepted'
  26. },
  27. {
  28. url: 'polsatnews.pl',
  29. type: 'banned'
  30. }
  31. ]
  32.  
  33. var colourMap = {
  34. night: {
  35. warning: '#3c2c2c',
  36. accepted: '#2c3c2c'
  37. },
  38. day: {
  39. warning: '#ffdddd',
  40. accepted: '#aaffaa'
  41. }
  42. }
  43.  
  44. // logic
  45. var theme = document.getElementsByTagName('body')[0].classList.contains('night') ? 'night' : 'light';
  46. var container = document.getElementById('itemsStream');
  47. var posts = container.getElementsByClassName('link');
  48.  
  49. Array.prototype.forEach.call(posts, function(post) {
  50. var source = post.querySelector('.tag.create a');
  51.  
  52. if (!source) return;
  53.  
  54. markedUrls.forEach(function(mark) {
  55. if (source.href.indexOf(mark.url) > -1) {
  56. if (mark.type === 'banned') {
  57. post.style.display = 'none';
  58. } else {
  59. post.style.backgroundColor = colourMap[theme][mark.type];
  60. }
  61. }
  62. })
  63. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement