Skip to content

Instantly share code, notes, and snippets.

@ezy
Forked from gmolveau/twitter_reset.md
Created April 5, 2020 05:36
Show Gist options
  • Save ezy/ba077e84e190663658879db03c67dd23 to your computer and use it in GitHub Desktop.
Save ezy/ba077e84e190663658879db03c67dd23 to your computer and use it in GitHub Desktop.
Twitter reset scripts

Twitter Reset

Ces scripts permettent de vider le flux d'activité d'un compte twitter : RT, likes, tweets.

Those scripts will flush your twitter activity feed : likes, RT, tweets...

Ces scripts ne fonctionnent que pour twitter en langue anglaise. (https://twitter.com/settings/language)

Those scripts only work for twitter in english.

Vous pouvez demander votre archive complète ici : https://twitter.com/settings/your_twitter_data

You can request your personal archive here : https://twitter.com/settings/your_twitter_data

Tweets + RT

Ce script permet de supprimer vos tweets, vos réponses, d'unliker vos retweets et de les supprimer.

This script will delete your tweets, answers, unlike your retweets and delete them.

Console

  • se rendre sur votre profil twitter.com > onglet Tweets & replies

go on your twitter profile > tab Tweets & replies

  • ouvrir la console

open your browser console

  • copier-coller l'intégralité du script ci-dessous

copy-paste the following script

  • appuyer sur la touche Enter

press Enter

function scrollBottom(){ window.scrollTo(0, document.body.scrollHeight || document.documentElement.scrollHeight) }
function containsAndVisible(selector, text) {
	return [].find.call(document.querySelectorAll(selector), function(element){
		return RegExp(text).test(element.textContent) && (element.offsetWidth > 0 && element.offsetHeight > 0);
	});
}
setInterval(function() {
	var timeline = document.querySelector('div[aria-label^="Timeline: "] > div > div');
	var tweet = timeline.querySelector('[data-testid="tweet"]');
	if (tweet == null){
		scrollBottom();
		return;
	}
	var dropdown = tweet.querySelector('[data-testid="caret"]');
	dropdown.click();
	setTimeout(function() {
		var remove = containsAndVisible("span", "Delete");
		if (remove !== undefined) {
			remove.click();
			document.querySelector('[role="menu"]').remove();
			tweet.remove();
			return;
		}
		document.querySelector('[role="menu"]').remove();
		var unlike = tweet.querySelector('div[data-testid="unlike"]');
		if (unlike != null) {
			unlike.click();
		}
		setTimeout(function() {
			var unretweet = tweet.querySelector('div[data-testid="unretweet"]');
			if (unretweet != null) {
				unretweet.click();
				containsAndVisible("span", "Undo Retweet").click();
			}
			tweet.remove();
		}, 500);		
	}, 500);
}, 1500);

Lancer via bookmarklet (favori)

  • créer un nouveau favori et coller le code ci-dessous dans le champ adresse/location

create a new bookmark, and paste the following code in the location field

go to your twitter profile > tab Tweets & replies

  • Cliquer sur le favori pour executer le script sur la page ouverte

click on the newly created bookmark to execute the script

javascript:function%20scrollBottom()%7Bwindow.scrollTo(0%2Cdocument.body.scrollHeight%7C%7Cdocument.documentElement.scrollHeight)%7Dfunction%20containsAndVisible(a%2Cb)%7Breturn%5B%5D.find.call(document.querySelectorAll(a)%2Cfunction(a)%7Breturn%20RegExp(b).test(a.textContent)%26%260%3Ca.offsetWidth%26%260%3Ca.offsetHeight%7D)%7DsetInterval(function()%7Bvar%20a%3Ddocument.querySelector('div%5Baria-label%5E%3D%22Timeline%3A%20%22%5D%20%3E%20div%20%3E%20div').querySelector('%5Bdata-testid%3D%22tweet%22%5D')%3Bnull%3D%3Da%3FscrollBottom()%3A(a.querySelector('%5Bdata-testid%3D%22caret%22%5D').click()%2CsetTimeout(function()%7Bvar%20b%3DcontainsAndVisible(%22span%22%2C%22Delete%22)%3Bvoid%200!%3D%3Db%3F(b.click()%2Cdocument.querySelector('%5Brole%3D%22menu%22%5D').remove()%2Ca.remove())%3A(document.querySelector('%5Brole%3D%22menu%22%5D').remove()%2Cb%3Da.querySelector('div%5Bdata-testid%3D%22unlike%22%5D')%2Cnull!%3Db%26%26b.click()%2CsetTimeout(function()%7Bvar%20b%3Da.querySelector('div%5Bdata-testid%3D%22unretweet%22%5D')%3Bnull!%3Db%26%26(b.click()%2CcontainsAndVisible(%22span%22%2C%22Undo%20Retweet%22).click())%3Ba.remove()%7D%2C500))%7D%2C500))%7D%2C1500)%3Bvoid+0

(via yourjs.com/bookmarklet/)

Likes

Ce script permet de supprimer les likes.

This script will delete and unretweet your likes.

Console

  • se rendre sur votre profil twitter.com > onglet Likes

go on your twitter profile > tab Likes

  • ouvrir la console

open your browser console

  • copier-coller l'intégralité du script ci-dessous

copy-paste the following code

  • appuyer sur la touche Enter

press Enter

function scrollBottom(){ window.scrollTo(0, document.body.scrollHeight || document.documentElement.scrollHeight) }
function containsAndVisible(selector, text) {
	return [].find.call(document.querySelectorAll(selector), function(element){
		return RegExp(text).test(element.textContent) && (element.offsetWidth > 0 && element.offsetHeight > 0);
	});
}
setInterval(function() {
	var timeline = document.querySelector('div[aria-label^="Timeline: "] > div > div');
	var tweet = timeline.querySelector('[data-testid="tweet"]');
	if (tweet == null){
		scrollBottom();
		return;
	}
	var unlike = tweet.querySelector('div[data-testid="unlike"]');
	if (unlike != null) {
		unlike.click();
	}
	setTimeout(function() {
		var unretweet = tweet.querySelector('div[data-testid="unretweet"]');
		if (unretweet != null) {
			unretweet.click();
			containsAndVisible("span", "Undo Retweet").click();
		}
		tweet.remove();
	}, 500);		
}, 1000);

Lancer via bookmarklet (favori)

  • créer un nouveau favori et coller le code ci-dessous dans le champ adresse/location

create a new bookmark, and paste the following code in the location field

  • se rendre sur votre profil twitter.com > onglet Likes

go to your twitter profile > tab Likes

  • Cliquer sur le favori pour executer le script sur la page ouverte

click on the newly created bookmark to execute the script

javascript:function%20scrollBottom()%7Bwindow.scrollTo(0%2Cdocument.body.scrollHeight%7C%7Cdocument.documentElement.scrollHeight)%7Dfunction%20containsAndVisible(a%2Cb)%7Breturn%5B%5D.find.call(document.querySelectorAll(a)%2Cfunction(a)%7Breturn%20RegExp(b).test(a.textContent)%26%260%3Ca.offsetWidth%26%260%3Ca.offsetHeight%7D)%7DsetInterval(function()%7Bvar%20a%3Ddocument.querySelector('div%5Baria-label%5E%3D%22Timeline%3A%20%22%5D%20%3E%20div%20%3E%20div').querySelector('%5Bdata-testid%3D%22tweet%22%5D')%3Bif(null%3D%3Da)scrollBottom()%3Belse%7Bvar%20b%3Da.querySelector('div%5Bdata-testid%3D%22unlike%22%5D')%3Bnull!%3Db%26%26b.click()%3BsetTimeout(function()%7Bvar%20b%3Da.querySelector('div%5Bdata-testid%3D%22unretweet%22%5D')%3Bnull!%3Db%26%26(b.click()%2CcontainsAndVisible(%22span%22%2C%22Undo%20Retweet%22).click())%3Ba.remove()%7D%2C500)%7D%7D%2C1E3)%3Bvoid+0

(via yourjs.com/bookmarklet/)

TODO

  • multi-langues

Enjoy

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