Skip to content

Instantly share code, notes, and snippets.

@kiki67100
Last active April 5, 2025 17:45
Show Gist options
  • Save kiki67100/6c68436766ea3a037508970999b7e89e to your computer and use it in GitHub Desktop.
Save kiki67100/6c68436766ea3a037508970999b7e89e to your computer and use it in GitHub Desktop.
Delete batch messages Microsoft Teams
/*
This version is probably out of date, look at the dsci4-hacks ( Thanks to him x) ) instead:
*** not tested ***
https://github.com/dsci4-hacks/Delete-Teams-Messages/blob/main/delete_my_teams_messages.js
Thank you for all your contributions in comments
**** Original ****
By kiki67100 https://gist.github.com/kiki67100
Tested on Google Chrome
Open Microsoft teams web version, select a conversation
Open Developper tools and copy / paste (Change YOUR_NAME by your)
Work on March 2020 maybe no work on the future...
*/
window.id = [];
YOUR_NAME = "YOUR_NAME";
window.idx=0;
setInterval(function() {
jQuery('#page-content-wrapper').find('div[id^=m]').each(function() {
$('virtual-repeat').scrollTop(0);
setTimeout(function(_this) {
//console.log('timeout...');
//console.log('_this = ',_this);
txt = $(_this).text();
if (txt.indexOf(YOUR_NAME) != -1) {
console.log('not inside');
$(_this).css({
'outline': '1px solid red'
});
_id = $(_this).attr('id');
//console.log('_this id =' + _id)
if (window.id.indexOf(_id) == -1) {
window.id.push(_id.substr(1));
//console.log('add');
} else {
//console.log('!!');
}
}else{
//console.log('already inside');
}
}, 1000, this);
});
}, 2000);
/*
- Extract messages id
On Google Chrome developper tools :
copy(id.join("\n"))
Delete a message, copy the ajax request and export as CURL (bash) (on network tools maybe end by "softDelete")
On notepad ++ on replace regex mode
REPLACE (.*)
Your CURL shell command find the id curl 'https://emea.[...]/121545326566?behavior=softDelete by $1 like this 'https://emea.[...]/$1?behavior=softDelete
lauch on linux terminal all lines
*/
@bakaschwarz
Copy link

Yeah, i am also kinda desparate ๐Ÿ˜…

@dsci4-hacks
Copy link

Yeah, i am also kinda desparate ๐Ÿ˜…

I have made a new version - you can test it https://github.com/dsci4-hacks/Delete-Teams-Messages-Batch-Bulk-Delete/blob/main/Delete_Teams_Messages_v2.0

@dsci4-hacks
Copy link

Hello

I'm quitting in 2 months, guys, I need you :D

I have made a new version - you can test it https://github.com/dsci4-hacks/Delete-Teams-Messages-Batch-Bulk-Delete/blob/main/Delete_Teams_Messages_v2.0

@dsci4-hacks
Copy link

Hello everyone. Script does not work with New Teams. The option to go back to Old Teams is not available anymore. Can the experts revise the code to work with New Teams? Regards!

I have made a new version - you can test it https://github.com/dsci4-hacks/Delete-Teams-Messages-Batch-Bulk-Delete/blob/main/Delete_Teams_Messages_v2.0

@geog2
Copy link

geog2 commented Dec 17, 2024

I have made a new version - you can test it https://github.com/dsci4-hacks/Delete-Teams-Messages-Batch-Bulk-Delete/blob/main/Delete_Teams_Messages_v2.0

hello @dsci4-hacks . Tested on chrome, firefox and edge and got this error "[Automation Script] Error processing message ID: xxx"
can someone test to confirm? regards

@geog2
Copy link

geog2 commented Feb 13, 2025

anyone?!?!!? everybody sleeping????????

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