Skip to content

Instantly share code, notes, and snippets.

@victor-torres
Last active February 4, 2024 12:40
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 victor-torres/9c7d6d6029ed7be425a1624ef57e9741 to your computer and use it in GitHub Desktop.
Save victor-torres/9c7d6d6029ed7be425a1624ef57e9741 to your computer and use it in GitHub Desktop.
This JavaScript code snippet can be pasted into Chrome's developer console in order to remove tweets.
/*
Copyright (c) 2017 Victor Torres
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Example of usage:
Paste the code below on Chrome's developer console and run this method when you're ready.
>>> deleteTweets()
You can test removing a single tweet before doing the batch process.
>>> deleteTweet()
When you're done with the batch process run the stop method.
>>> stop()
*/
function deleteTweet() {
// Deletes first tweet on page
$(".js-actionDelete")[0].click()
$(".delete-action")[0].click()
// FIXME: not able to undo retweets
}
var interval = null;
function deleteTweets() {
if (interval != null) return;
// It's useful to wait 3s, otherwise
// requests may be rejected by Twitter.
interval = setInterval(deleteTweet, 3000);
}
function stop() {
clearInterval(interval);
interval = null;
}
@dongarchive
Copy link

dongarchive commented Jun 4, 2018

function deleteTweet() {
    // Deletes first tweet on page
    $(".js-actionDelete")[0].click()
    $(".delete-action")[0].click()
  
}

function scroll() {
  $("html, body").animate({ scrollTop: $(document).height() }, 1000);
}

var interval = null;

function deleteTweets() {
  
  if (interval != null) return;

  setInterval(deleteTweet, 3000);
  setInterval(scroll, 10000);
}

function stop() {
  clearInterval(interval);
  interval = null;
}

Added an interval to scroll down to the bottom of the page after a period of time as the script stops because tweets are not being loaded

@victor-torres
Copy link
Author

Cool!

@iMaz1n
Copy link

iMaz1n commented May 16, 2022

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