Created
September 30, 2016 23:11
-
-
Save karmankertesz/d5698e5d31ab35aa23568451d850cfef to your computer and use it in GitHub Desktop.
Console commands to delete Disqus comments
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
/* | |
These are Javascript console commands to delete your public Disqus comments to protect your privacy. | |
Keep in mind: | |
"Comments are not anonymized when they are deleted and can still be seen by moderators." | |
https://help.disqus.com/customer/portal/articles/466229 | |
Open your profile page: | |
https://disqus.com/by/<username>/comments/ | |
Open Chrome console. | |
1. inject jQuery on the page | |
*/ | |
var jq = document.createElement('script'); | |
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
/* wait for loading then: */ | |
jQuery.noConflict(); | |
/* | |
Open the Network tab to see the queries. Edit or delete a comment and capture the API key from the request. | |
In the console save it in a variable: | |
*/ | |
var APIKEY = 'YYUh5lXXXX6gD8U3KyYYYIAXXXXXXXWSjZvCLXXXXXXXDrLilk2F'; | |
/* collect post IDs*/ | |
var postids = []; | |
$('a.time').each(function(i,e){ | |
postids.push($(this).attr('href').replace(/\/.*comment-/,'')); | |
}); | |
/* Overwrite the content of all comments on the page:*/ | |
jQuery.each(postids,function(i,e){ | |
jQuery.post('https://disqus.com/api/3.0/posts/update.json',{post:e, message:"This comment has been overwritten", | |
api_key:APIKEY}) | |
}); | |
/* Delete all comments on the page:*/ | |
jQuery.each(postids,function(i,e){ | |
jQuery.post('https://disqus.com/api/3.0/posts/remove.json',{post:e, | |
api_key:APIKEY}) | |
}); | |
/* When done, refresh the page to get more comments.*/ | |
/* To delete you account, see this page: | |
https://help.disqus.com/customer/portal/articles/472013 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks a lot for your reply!
I found it! I just have 2 comments (pun intended):
The id in the array
postids
have anhttps:
in front (ei:['https:54545647169', 'https:40362866757']
. A quick workaround is to replace line 30 by :postids.push($(this).attr('href').replace(/\/.*comment-/,'').replace("https:",""));
For the other users (Some trick I struggle to find):
-if you can't edit some comments (you get
400 (BAD REQUEST)
): it might be becauseComment edit period expired
(they can't be overwritten after this date). But they can still be deletedif the explanation is not clear in the console, go to the Network tab, select the request done and select the tab "response".
If you get the error
403 FORBIDDEN
, check your API key (I mistakenly put a space after it).you can delete all the comments of specific websites (eg. aaa.com)