diff options
author | 2019-07-29 19:22:54 +0000 | |
---|---|---|
committer | 2019-07-30 02:22:54 +0700 | |
commit | 0b40361983b362d028fac2fe0fed9486134fa41e (patch) | |
tree | 8e969ca16a81547ce222131fcffb7c35a0241bdd /source/libs/utils.ts | |
parent | 9e86863b2c2ba6b4a2dee12b335bd4dcc962f1c1 (diff) | |
download | refined-github-0b40361983b362d028fac2fe0fed9486134fa41e.tar.gz refined-github-0b40361983b362d028fac2fe0fed9486134fa41e.tar.zst refined-github-0b40361983b362d028fac2fe0fed9486134fa41e.zip |
`show-names`: Replace username with real name if they’re the same (#2193)19.7.30
Diffstat (limited to 'source/libs/utils.ts')
-rw-r--r-- | source/libs/utils.ts | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/source/libs/utils.ts b/source/libs/utils.ts index 9fe914c2..68e23594 100644 --- a/source/libs/utils.ts +++ b/source/libs/utils.ts @@ -114,6 +114,10 @@ export function getOP(): string { return select('.timeline-comment-header-text .author')!.textContent!; } +export function compareNames(username: string, realname: string): boolean { + return username.replace(/-/g, '').toLowerCase() === realname.normalize('NFD').replace(/[\u0300-\u036f\W.]/g, '').toLowerCase(); +} + export async function poll<T>(callback: () => T, frequency: number): Promise<T> { return new Promise(resolve => { (function loop() { |