Created
June 22, 2021 04:45
-
-
Save Weiyuan-Lane/925c9a78f65232719c831fbb494c8b3c to your computer and use it in GitHub Desktop.
Remove gitlab comments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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