Advertisement
Guest User

comment purge

a guest
Nov 17th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Comment purge
  3. // @version 1.0.1
  4. // @author Manish Goregaokar (http://stackapps.com/users/10098/manishearth)
  5. // @description One-click comment purges
  6. // @license GNU GPL v3 (http://www.gnu.org/copyleft/gpl.html)
  7. // @include http://*stackoverflow.com/*
  8. // @include http://*superuser.com/*
  9. // @include http://*serverfault.com/*
  10. // @include http://*stackexchange.com/*
  11. // @include http://discuss.area51.com/*
  12. // ==/UserScript==
  13.  
  14. function with_jquery(f) {
  15. var script = document.createElement("script");
  16. script.type = "text/javascript";
  17. script.textContent = "(" + f.toString() + ")(jQuery)";
  18. document.body.appendChild(script);
  19. };
  20.  
  21.  
  22. with_jquery(function($){
  23. $('document').ready(function(){
  24. var htm=$('.post-menu').html()||"";
  25. if(htm!=-1&&$('[id^=close-question] span').length!=0){
  26. return;
  27. }
  28. $('.post-menu').append($('<span class="lsep">|</span><a class="purge" href="javascript:void(0)" title="Purge comments">purge</a>'));
  29. $('.purge').bind("click",function(){
  30.  
  31. var postid=$(this).closest('div.question,div[id^=answer]').data('questionid')||$(this).closest('div.question,div[id^=answer]').data('answerid');
  32. $.post('/admin/posts/'+postid+'/delete-comments',{'mod-actions':'delete-comments',
  33. 'duration':1,
  34. 'target-post-id':postid,
  35. 'fkey':StackExchange.options.user.fkey});
  36. return false;
  37. });
  38. });
  39. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement