Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. var deleteSpam = {
  2. count: 0,
  3. list: null,
  4. tiemout: 500,
  5. //Selector for cross(x) icon, look for <i> tag
  6. crossSelector: '.userContentWrapper .sx_477a95',
  7. //Selector for buttons wrapper in overlay box which appears when we click on cross icon
  8. overlayPresenseSelector: '.uiOverlayFooter',
  9. //Delete button selector on overlay box
  10. confirmDeleteButtonSelector: 'button.layerConfirm',
  11. init: function() {
  12. this.list = document.querySelectorAll(this.crossSelector);
  13. this.overlay();
  14. },
  15. checkOverlay: function() {
  16. var that = this;
  17. var overlay = document.querySelector(this.overlayPresenseSelector);
  18. if (!overlay) {
  19. this.overlay();
  20. } else {
  21. setTimeout(function() {
  22. that.checkOverlay();
  23. }, this.timeout);
  24. }
  25. },
  26. overlay: function() {
  27. var that = this;
  28. var event = document.createEvent('HTMLEvents');
  29. event.initEvent('click', true, false);
  30.  
  31. if (this.list.length <= this.count) {
  32. return false;
  33. }
  34. this.list[this.count].offsetParent.dispatchEvent(event);
  35. setTimeout(function() {
  36. that.confirm();
  37. }, this.timeout);
  38. },
  39. confirm: function() {
  40. var that = this;
  41. var button = document.querySelector(this.confirmDeleteButtonSelector);
  42. var event = document.createEvent('HTMLEvents');
  43. event.initEvent('click', true, false);
  44.  
  45. if (button) {
  46. button.dispatchEvent(event);
  47. this.count++;
  48. setTimeout(function() {
  49. that.checkOverlay();
  50. }, this.timeout);
  51. } else {
  52. setTimeout(function() {
  53. that.confirm();
  54. }, this.timeout);
  55. }
  56. }
  57. }.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement