forked from alirezakargar1380/delete_tweetes_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delete_tweets.js
63 lines (53 loc) · 2.12 KB
/
delete_tweets.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**--------------------- READ THIS BEFORE RUN ----------------**/
/**
* Timeout:
* this timeout is in seconds, if you set this to 5,
* every 5 second, this script will run
*
* NOTE:
* increase timeout if any suspend or rate limit happens
*/
var timeout = 5;
/**--------------------- DON'T Change This SECTION - START ----------------**/
// START - app variables
// NOTE:
// Don't change this
var deletedTweets = 0;
timeout = timeout * 1000
// END - app settings
/**--------------------- DON'T Change This SECTION - END ----------------**/
var delTweets = function () {
// get all your tweets number
var tweetsRemaining = document.querySelectorAll('[role="heading"]+div')[1].textContent;
console.log('Remaining: ', tweetsRemaining + ', deleted:', deletedTweets);
// delete tweets
document.querySelectorAll('article[data-testid="tweet"]').forEach(function (tweetsArticle) {
tweetsArticle.querySelectorAll('[aria-label="More"]').forEach(async function (v, i, a) {
v.click();
// IS TRUE
await new Promise((resolve) => setTimeout(resolve, 500));
document.querySelectorAll('[role="menuitem"]').forEach(async function (v2, i2, a2) {
if (v2.textContent === 'Delete') {
v2.click();
await new Promise((resolve) => setTimeout(resolve, 500));
document.querySelectorAll('[data-testid="confirmationSheetConfirm"]').forEach(function (v3, i3, a3) {
v3.click();
deletedTweets++
});
}
});
});
});
// un retweet tweets
document.querySelectorAll('[data-testid="unretweet"]').forEach(function (v3, i3, a3) {
v3.click();
document.querySelectorAll('[data-testid="unretweetConfirm"]').forEach(function (v5) {
deletedTweets++
v5.click();
});
});
// scroll down to load more tweets
window.scrollBy(0, 3000);
}
setInterval(delTweets, timeout); // run script multipile times
delTweets(); // run for the first time