Skip to content

Instantly share code, notes, and snippets.

@karmankertesz
Created September 30, 2016 23:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karmankertesz/d5698e5d31ab35aa23568451d850cfef to your computer and use it in GitHub Desktop.
Save karmankertesz/d5698e5d31ab35aa23568451d850cfef to your computer and use it in GitHub Desktop.
Console commands to delete Disqus comments
/*
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
*/
@WiliTest
Copy link

WiliTest commented Dec 12, 2021

Thanks for sharing! I'm trying to get the API key from the remove.json (I copied it in the network tab after deleting a comment ― I'm super excited to know this trick!). But which one is the API key (your API key has 52 characters, but there is no string of 52 characters in my JSON. Is it inside one of those fields? If so, which one?

    "response": 
        "id
        "author": {
            "id
            "emailHash
            "anonymizedIdentifier        ((it might be this one: 128 random characters string))
        

@karmankertesz
Copy link
Author

Hi,

The API key should be in the request payload, not the response.
When you post, edit or delete a comment, find the network request with create.json or update.json or remove.json and look at the payload tab of the request.
That should contain "form data" with the values for the post, the message text (if editing) and the api_key:

d1

@WiliTest
Copy link

WiliTest commented Dec 13, 2021

Thanks a lot for your reply!

I found it! I just have 2 comments (pun intended):

  1. The id in the array postids have an https: 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:",""));

  2. 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 because Comment edit period expired (they can't be overwritten after this date). But they can still be deleted

  • if 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)

var postidsaaa = [];

$('a.time').each(function(i,e){
if ($(this).attr('href').includes("aaa.com")){
 postidsaaa.push($(this).attr('href').replace(/\/.*comment-/,''));}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment