Guest User

Untitled

a guest
Feb 1st, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Image destroyer
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description asd
  6. // @author You
  7. // @include https://ponyach.ru/*
  8. // @include https://ponyach.ga/*
  9. // @grant none
  10. // ==/UserScript==
  11. /* jshint -W097 */
  12. 'use strict';
  13.  
  14. var names = ['Cpt. Wolf', 'Murky'];
  15.  
  16. $(function() {
  17. $('.pstnode').each(function() {
  18. removePostFiles($(this));
  19. });
  20.  
  21. runObserver('.pstnode', removeMutationPostFiles);
  22. });
  23.  
  24. function removeMutationPostFiles(mutation) {
  25. var $addedNodes = $(mutation.addedNodes);
  26. $addedNodes.each(function() {
  27. removePostFiles($(this));
  28. });
  29. }
  30.  
  31. function removePostFiles($postObj) {
  32. var posterName = $postObj.find('.postername').text().trim();
  33. names.some(function(name) {
  34. if (posterName === name) {
  35. $postObj.find('.post-files').remove();
  36. return true;
  37. }
  38.  
  39. return false;
  40. });
  41. }
  42.  
  43. function runObserver(selector, mutationCallback) {
  44. var target = document.querySelector(selector);
  45. var observer = new MutationObserver(function(mutations) {
  46. mutations.forEach(mutationCallback);
  47. });
  48. var config = { attributes: true, childList: true, characterData: true }
  49. observer.observe(target, config);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment