Skip to content

Instantly share code, notes, and snippets.

@Weiyuan-Lane
Created June 22, 2021 04:45
Show Gist options
  • Save Weiyuan-Lane/925c9a78f65232719c831fbb494c8b3c to your computer and use it in GitHub Desktop.
Save Weiyuan-Lane/925c9a78f65232719c831fbb494c8b3c to your computer and use it in GitHub Desktop.
Remove gitlab comments
function hideCommentsBy(username) {
let hiddenCommentCount = 0;
$('.discussion-notes.diff-discussions').each((_, elem) => {
const $elem = $(elem);
const foundTags = $elem.find(`a[data-username="${username}"]`)
if (foundTags.length > 1) {
throw new Error('More than one tag found per comment. Code might not work due to changes made on Gitlab frontend');
} else if (foundTags.length == 0) {
return; // comment not matching username
}
$elem.remove();
hiddenCommentCount++;
});
$('.diff-grid-comments.diff-tr.notes_holder').each((_, elem) => {
const $elem = $(elem);
const foundTags = $elem.find(`a[data-username="${username}"]`)
if (foundTags.length == 0) {
$elem.remove();
}
});
return hiddenCommentCount;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment