How to mass-delete spam posts in a forum

In the recent days our forum has been hit by 100s of fake sign-ups and spam post. But they have come to the wrong forum, this forum is the home of the open-source web automation software :laughing:

So… we simply wrote a small macro that runs in a loop and deletes all spam posts:

mass delete spammer accounts on discourse forum

As you can see from the GIF, we use XCLICK+image-recognition to find the buttons. An alternative method would have been the classic “Selenium IDE way” with CLICK+xpath locator. But this requires some time investment to get around the changing xpath locators. Each “Delete User” button has its own Xpath. Visual automation does not have this issue. So while the image-recognition macro runs slower, it was much faster to create.

3 Likes

Improved version. We include an informative text now, so real users can contact us to get their forum account enabled:

Source code:

{
  "Name": "removeforumspam",
  "CreationDate": "2024-8-19",
  "Commands": [
    {
      "Command": "store",
      "Target": "fast",
      "Value": "!replayspeed",
      "Description": ""
    },
    {
      "Command": "store",
      "Target": "User deleted by Ui.Vision Anti-Spam Macro. If you are a real person and not a robot, please contact team@ui.vision and we will enable to your account. In your email, please mention this message ID: 3081",
      "Value": "!clipboard",
      "Description": ""
    },
    {
      "Command": "times",
      "Target": "1008",
      "Value": "",
      "Description": "Loop until list empty. Then macro stops with error, which is ok"
    },
    {
      "Command": "XClick",
      "Target": "del_dpi_168.png",
      "Value": "",
      "Description": "Delete user button, triggers dropdown menu"
    },
    {
      "Command": "XType",
      "Target": "${KEY_UP}",
      "Value": "",
      "Description": "in dropdown that shows, select 2nd entry"
    },
    {
      "Command": "XType",
      "Target": "${KEY_ENTER}",
      "Value": "",
      "Description": "select entry"
    },
    {
      "Command": "XClick",
      "Target": "why_dpi_168.png",
      "Value": "",
      "Description": "set focus in box"
    },
    {
      "Command": "XType",
      "Target": "${KEY_CTRL+KEY_V}",
      "Value": "",
      "Description": "Enter text from clipboard"
    },
    {
      "Command": "XClick",
      "Target": "send_dpi_168.png",
      "Value": "",
      "Description": "check box"
    },
    {
      "Command": "XClick",
      "Target": "del2_dpi_168.png",
      "Value": "",
      "Description": "Delete it! :)"
    },
    {
      "Command": "XMove",
      "Target": "1,2",
      "Value": "",
      "Description": "move cursor off screen, so that it does not overlay on DELETE button and change its color."
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    }
  ]
}
1 Like