Last active
March 1, 2016 04:36
-
-
Save sunnyluthra/525b687ec2f1aed6962e to your computer and use it in GitHub Desktop.
It will delete all the pending posts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var deleteSpam = { | |
count: 0, | |
list: null, | |
timeout: 500, | |
//Selector of cross(x) link | |
crossSelector: '.userContentWrapper [aria-label="Delete"]', | |
//Selector for buttons wrapper in overlay box which appears when we click on cross icon | |
overlayPresenseSelector: '.uiOverlayFooter', | |
//Delete button selector on overlay box | |
confirmDeleteButtonSelector: 'button.layerConfirm', | |
init: function() { | |
this.list = document.querySelectorAll(this.crossSelector); | |
this.overlay(); | |
}, | |
checkOverlay: function() { | |
var that = this; | |
var overlay = document.querySelector(this.overlayPresenseSelector); | |
if (!overlay) { | |
this.overlay(); | |
} else { | |
setTimeout(function() { | |
that.checkOverlay(); | |
}, this.timeout); | |
} | |
}, | |
overlay: function() { | |
var that = this; | |
var event = document.createEvent('HTMLEvents'); | |
event.initEvent('click', true, false); | |
if (this.list.length <= this.count) { | |
return false; | |
} | |
this.list[this.count].dispatchEvent(event); | |
setTimeout(function() { | |
that.confirm(); | |
}, this.timeout); | |
}, | |
confirm: function() { | |
var that = this; | |
var button = document.querySelector(this.confirmDeleteButtonSelector); | |
var event = document.createEvent('HTMLEvents'); | |
event.initEvent('click', true, false); | |
if (button) { | |
button.dispatchEvent(event); | |
this.count++; | |
setTimeout(function() { | |
that.checkOverlay(); | |
}, this.timeout); | |
} else { | |
setTimeout(function() { | |
that.confirm(); | |
}, this.timeout); | |
} | |
} | |
}.init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment