Skip to content

Instantly share code, notes, and snippets.

@kiki67100
Last active November 5, 2024 14:04
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
*/
@geog2
Copy link

geog2 commented Jun 12, 2024

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!

@bnff
Copy link

bnff commented Sep 30, 2024

Hello

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

@bakaschwarz
Copy link

Yeah, i am also kinda desparate 😅

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