@funfab/sdk 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -2
- package/adapters/party.mjs +8 -0
- package/adapters/stream.mjs +242 -0
- package/adapters/vercel.mjs +159 -0
- package/browser.js +115 -0
- package/host-safety/index.js +2 -0
- package/host-safety/name-filter.js +1151 -0
- package/host-safety/public-names.js +86 -0
- package/index.js +2 -0
- package/package.json +43 -4
- package/schemas/host-safety.schema.json +69 -0
- package/server.mjs +89 -0
|
@@ -0,0 +1,1151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The viewer-name floor for every hosted stream game: one module, so a name one game keeps off the stream is kept off
|
|
3
|
+
* all of them. Pure ESM with no imports: it runs in the browser (boards, panels) and in Node (servers, tests).
|
|
4
|
+
*
|
|
5
|
+
* CANONICAL FILE: prototypes/live-chat/web/name-filter.js. Each game serves its own copy as <game>/name-filter.js
|
|
6
|
+
* (prototypes/stream-games.json lists them); edit this file, then `npm run sync:live-chat`. Each game's own module
|
|
7
|
+
* (chat.js, or names.js) imports its copy and re-exports, so callers don't change.
|
|
8
|
+
*
|
|
9
|
+
* Until 2026-10-20 there were four copies that had drifted apart: the shared chat.js block (Which Way, Chat?, Don't Say
|
|
10
|
+
* It!, Pop Words, Hot Seat, Flock, Cat Café, Emote Defense), Would You Date?'s names.js (the sexual words, whole-word
|
|
11
|
+
* rape/sex/cum/anal, a slur in Cyrillic), Rip Night's names.js (Would You Date?'s plus the RN-2026-10-19 lines: Cherokee
|
|
12
|
+
* look-alikes, allowed whole words, codes split by separators, unknown letters as "?", "the rapist") and Delve's chat.js
|
|
13
|
+
* (Beat the Slime King: bidi overrides, its word-start rules, more look-alikes). This is their union, the strictest
|
|
14
|
+
* reading of each rule, loosened only where a family's tests pass a name (prototypes/live-chat/name-filter.test.js runs
|
|
15
|
+
* every family's lists through every game). Every game reads a name the same way: Delve's reading across the gap
|
|
16
|
+
* between words is gone (the owner, 2026-10-20), so "Toni Grande" passes in every game.
|
|
17
|
+
*
|
|
18
|
+
* TWO CHECKS (2026-10-20, after review rounds on #1941 kept finding that narrowing one rule let some name develop hid
|
|
19
|
+
* through): LEGACY, develop's filter as merged at f7f541e4, frozen verbatim at the end of this file, and the strict
|
|
20
|
+
* check, everything this file adds (every look-alike Unicode gives a Latin prototype, Lisu, Canadian Syllabics,
|
|
21
|
+
* Runic, Tifinagh, transliterations, Roman 8s, folding before NFKC) on top of develop's reading. A name shows only when
|
|
22
|
+
* both pass, so no change here can show a name develop hid. Never edit LEGACY; change the strict check above it.
|
|
23
|
+
*
|
|
24
|
+
* A FLOOR, not a moderation system. An adversarial pass on 2026-09-25 put 64 hostile handles through an earlier version
|
|
25
|
+
* of the list and 46 got through. It still won't catch a determined person: a targeted threat like "kill_<streamer>"
|
|
26
|
+
* can't be caught by a stem list without blocking "killerqueen" and "skillz" too. The real answer is the channel's own
|
|
27
|
+
* mods, whose bans reach the boards (Twitch CLEARCHAT). Matching is done on de-obfuscated copies of the name (look-alike
|
|
28
|
+
* letters, accents and leetspeak folded) so the usual evasions don't walk straight through.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
export const MAX_NAME = 25; // Twitch's own limit
|
|
32
|
+
|
|
33
|
+
/** The extremist stems: part of NAME_DENY, and what makes a word a hate companion of an allowed word (ALLOW_WORDS).
|
|
34
|
+
* (kkk is in the pt-BR block below: kkkk and joao_kkk are Brazilian laughter.) */
|
|
35
|
+
const EXTREMIST = [/(?<!w)hitl/, "heil", "sieghei", "whitepower", "gaschamber", "lynching", "lynchmob", /nazi(?!r)/,
|
|
36
|
+
"auschwitz", "holohoax", "holocaust", "whitepride", /adolf(?!o)/];
|
|
37
|
+
/** Matched on the de-obfuscated copy with separators stripped, but never from the last letter or two of one word into
|
|
38
|
+
* the next (ptLegacyUnsafe, in the floor below). A string matches anywhere; a regex's lookarounds see the whole name. */
|
|
39
|
+
const NAME_DENY = [
|
|
40
|
+
// Impersonating the platform, however it's separated ("TikTok_Admin", "tik tok support", "Twitch_Official").
|
|
41
|
+
// (TikTok_Moda and youtube_moda, fashion accounts, pass: the es draft. TikTok_Mod and tiktokmoderator don't.)
|
|
42
|
+
"tiktokadmin", "tiktoksupport", "tiktokstaff", "tiktokofficial", /tiktokmod(?!as?$)/, "tiktokteam", "tiktokpartner",
|
|
43
|
+
"twitchstaff", "twitchsupport", "twitchadmin", /twitchmod(?!as?$)/, "twitchofficial", "twitchteam", "twitchpartner",
|
|
44
|
+
"youtubestaff", "youtubesupport", "youtubeofficial", "youtubeadmin", /youtubemod(?!as?$)/, "youtubeteam", "youtubepartner",
|
|
45
|
+
// Slurs. Pakistão, retardar and retardatário pass (the pt-BR draft); hospício, auspicioso and perspicaz too;
|
|
46
|
+
// kikeriki (a rooster's crow), Van Dyke and vandyke pass as whole words only (ALLOW_WORDS).
|
|
47
|
+
"nigg", "nigr", "faggot", "fagg", "tranny", "kike", /spic(?![aeiy])/, "chink", "wetback", /(?<!rac|ty|co)coon/,
|
|
48
|
+
"beaner", "gook", "raghead", "towelhead", /paki(?!sta[no])/, "dyke", "shemale", /retard(?!a[rt])/, "spastic",
|
|
49
|
+
"mongoloid",
|
|
50
|
+
// Extremist (EXTREMIST, below).
|
|
51
|
+
...EXTREMIST,
|
|
52
|
+
// Threats and self-harm. Deliberately narrow: "kill" alone is far too common in real handles (killerqueen, skillz).
|
|
53
|
+
"kys", "killurself", "killyourself", "killyrself", "swatting", /(?<!the|te)rapist/, "iwillkill", // terapista, fisioterapista
|
|
54
|
+
"slityourwrist", "hangyourself", "neckyourself",
|
|
55
|
+
// Sexual (Would You Date?'s pre-live gate: r4pe_u, onlyfans_link, pornhub_com).
|
|
56
|
+
"porn", "onlyfans", "fansly", "hentai", "camgirl", "camwhore", "sexy", "milf", "dildo", "boobs",
|
|
57
|
+
"pussy", "slut", "whore", /(?<!t)horny/, "blowjob", "handjob", "cumshot",
|
|
58
|
+
// Child-safety. These have no innocent reading in a handle.
|
|
59
|
+
// torpedo, pedometer, pedômetro (Slime King's rule); qué pedo, and Loli Contreras or Concepción (the es draft)
|
|
60
|
+
/(?<!tor|que)pedo(?!met)/, "pedofil", "pedophil", "groomer", "jailbait", /lolicon(?!treras|cepcion|suegra|tento|tador|stantin|de$)/, "childp",
|
|
61
|
+
// Scams: the ones that turn an overlay into a phishing surface.
|
|
62
|
+
"freebits", "freesubs", "freenitro", "giveawaybot", "clickhere",
|
|
63
|
+
];
|
|
64
|
+
/** Whole words only (on the separator-split copy, and with a spelled-out run of single letters as one word: "r.a.p.e"),
|
|
65
|
+
* where a substring would hit ordinary words: "rape" starts a word in r4pe_u but sits inside grape, drape and scrape
|
|
66
|
+
* (Would You Date?). A word that starts "rape" blocks (rapelover, RapeLord) unless it is one of the innocent whole
|
|
67
|
+
* words that do (the owner, 2026-10-20): Spanish rapero/rapera (a rapper), English rapeseed, Portuguese rapei, rapem,
|
|
68
|
+
* rapemos (rapar). Rapel (rappelling, in Which Way, Chat?'s pt-BR deck, which dial/check-deck.test.js holds to this
|
|
69
|
+
* filter) passes only as the whole name: ALLOW_ALONE. */
|
|
70
|
+
const WORD_DENY = [/^rape(?!(?:i|is|m|mos|n|ros?|ras?|seeds?)$)/, /^raping$/, /^sex$/, /^cum$/, /^anal$/];
|
|
71
|
+
/** English entries read the pt-BR palavra way (a whole word, plural -s, a run of a letter, spelled out): nude, nudes,
|
|
72
|
+
* n.u.d.e, nud3, not denude, menudear, estornude or nudez (the owner, 2026-10-20). */
|
|
73
|
+
const EN_PALAVRA = ["nude"];
|
|
74
|
+
/** On the spaced copy (separators, and camelCase humps in one reading, as single spaces), where a joined copy can't
|
|
75
|
+
* tell: "the_rapist" and "TheRapist" read "therapist" joined (Rip Night, RN-2026-10-19). With Slime King's word-start
|
|
76
|
+
* rules (the 2026-10-15 pre-live review), which name the innocent continuations they let through. */
|
|
77
|
+
const SPACED_DENY = [/\bthe rapist/,
|
|
78
|
+
/(?<!the|te)rapist/, /(?<!tor|que ?)pedo(?!met)/, /\bspic(?![yeau])/, /\bcoon(?!an|ey|ie)/, /\bnazi(?![ar])/,
|
|
79
|
+
/(?<!van )\bdyke/, /\bheil(?:\b|[hs])/, /\bpaki(?!ze|sta[no]|sh)/, /\bkys\b/, /\bgook/, /\bkike(?!riki)/, /\bchink(?!apin)/];
|
|
80
|
+
/** Ordinary names a substring rule hits (Slime King's review: Nazia, Heilmann, Pakize, Coonan; and Sheila; Would You
|
|
81
|
+
* Date?'s kikeriki and Van Dyke). Only a WHOLE word is let through: no letter glued on either side ("naziarmy",
|
|
82
|
+
* "NaziaArmy", "kkkxNazia" block), but separators and digits are word breaks ("nazia2001" passes), on the NFKC copy
|
|
83
|
+
* (squared or full-width letters read as plain). And only beside ordinary words: the exemption is off, and the name is matched like any other, when the rest of it holds a Nazi number
|
|
84
|
+
* (HATE_NUMBER, in digits of any script, split or not: "Heilmann_88", "nazia_8_8", "nazia_๘๘"), an extremist stem
|
|
85
|
+
* (EXTREMIST: "Sheila_Heil"), a Klan or Nazi word (HATE_COMPANION, leetspeak and look-alikes folded: "Sieg_Heilmann",
|
|
86
|
+
* "Nazia_$$", "Coonan_k|an"), or a second allowed word. "Nazia_Khan", "sheila_99", "Sheila White" and "Coonan Boys"
|
|
87
|
+
* pass. */
|
|
88
|
+
const ALLOW_WORDS = ["nazia", "heilmann", "sheila", "pakize", "coonan", "kikeriki", "vandyke", "van[\\s._-]+dyke"];
|
|
89
|
+
const ALLOWED = new RegExp(`(?<!\\p{L})(?:${ALLOW_WORDS.join("|")})(?!\\p{L})`, "giu");
|
|
90
|
+
/** Klan and Nazi words that make an allowed word read as what it holds: specific terms only, never ordinary words
|
|
91
|
+
* (white, power, grand, boys, the). "army" and "party" stay: "Nazia Army", "Nazia Party" read as nazi army, Nazi Party. Matched on the folded and leet-read
|
|
92
|
+
* rest of the name, a spelled-out run of single letters as one word ("s.i.e.g"). */
|
|
93
|
+
const HATE_COMPANION = /^(?:sieg|siegs|heils?|hh|sss?|ns|nsdap|kkk+|klans?|klux|kluxer|reichs?|fuhrers?|fuehrers?|wehrmacht|waffen|swastikas?|hakenkreuz|gestapo|totenkopf|aryans?|army|armies|armee|heer|party|xiv|lxxxviii)$/;
|
|
94
|
+
/** Nazi and hate numbers (88 HH, 14 words, 18 AH, 28 BH, 83 HC, 311 KKK, and the 1488 family). */
|
|
95
|
+
const HATE_NUMBER = /^(?:88|14|18|28|83|311|148|1418|8888|1488|8814)$|1488|8814/;
|
|
96
|
+
/** Passes only as the whole name, nothing beside it: "Rapel" (a deck word), not "rapel_her" or "rapel lover". */
|
|
97
|
+
const ALLOW_ALONE = /^rapels?$/;
|
|
98
|
+
/** The name with its allowed words set aside (" " for a whole-name ALLOW_ALONE word), or the name itself when the
|
|
99
|
+
* rest of it says otherwise. */
|
|
100
|
+
function exempt(s) {
|
|
101
|
+
const words = ptWords(letters(ptHumps(s)));
|
|
102
|
+
if (words.length === 1 && ALLOW_ALONE.test(words[0]) && !/[\p{N}\p{L}]/u.test(s.replace(/[a-z]/gi, ""))) return " ";
|
|
103
|
+
const base = romanDigits(s).normalize("NFKC"), kept = base.replace(ALLOWED, " ");
|
|
104
|
+
if (kept === base) return s;
|
|
105
|
+
if ((base.match(ALLOWED) || []).length > 1) return s; // one allowed word ("nazia nazia" isn't a name)
|
|
106
|
+
// numbers in digits of any script (Roman numerals and keycaps too), joined across separators ("8_8", "1.4.8.8", "ⅧⅧ"),
|
|
107
|
+
// and Roman numerals spelled in letters, as a game that NFKC-folds a name first hands them over ("VIIIVIII", "XIV")
|
|
108
|
+
if ((asciiDigits(kept).replace(/[\p{Cf}\p{M}\s._\-]+/gu, "").match(/[0-9]+/g) || []).some((n) => HATE_NUMBER.test(n))) return s;
|
|
109
|
+
if (letters(kept).split(/[^a-z]+/).some((w) => /^[ivxl]+$/.test(w) && HATE_NUMBER.test(romanWord(w)))) return s;
|
|
110
|
+
const hate = (w) => HATE_COMPANION.test(w) || EXTREMIST.some((r) => (typeof r === "string" ? w.includes(r) : r.test(w)));
|
|
111
|
+
// SS bolts and 8-balls stand for SS and 88 beside a name that holds nazi or heil
|
|
112
|
+
if (/\u26A1\uFE0F?[\s._-]*\u26A1|\u{1F3B1}[\s._-]*\u{1F3B1}/u.test(kept)) return s;
|
|
113
|
+
// enclosed letters and regional indicators are words here too, each run its own ("nazia_🅢🅢", "nazia 🇭🇭"), and a run
|
|
114
|
+
// of any length that is unsafe on its own ("Nazia 🇰🇮🇰🇪") takes the exemption away
|
|
115
|
+
// (one real flag is a flag: "🇸🇸 Nazia" is South Sudan; "nazia 🇭🇭" isn't a flag)
|
|
116
|
+
const flagless = kept.replace(REGIONAL_RUN, (r) => { const u = unEnclose(r).replace(/[^a-z]/g, ""); return u.length === 2 && FLAGS.has(u) ? " " : r; });
|
|
117
|
+
const runs = [...(flagless.match(ENCLOSED_RUN) || []), ...(flagless.match(REGIONAL_RUN) || [])].map(unEnclose);
|
|
118
|
+
if (runs.some((r) => !checkOne(r))) return s;
|
|
119
|
+
const h = ptHumps(flagless.replace(ENCLOSED_RUN, (r) => ` ${unEnclose(r)} `).replace(REGIONAL_RUN, (r) => ` ${unEnclose(r)} `)
|
|
120
|
+
.replace(/\|-\|/g, "h").replace(/\u20AC/g, "e").replace(/\u00A5/g, "y").replace(/[\u00DF\u1E9E]/g, "ss").replace(/\u0282/g, "s") // reic|-|, r€ich, Arm¥, ß
|
|
121
|
+
.replace(/(^|[^\p{L}\p{N}|!])[|!]+(?=[\p{L}\p{N}])/gu, "$1 ") // "Nazia|k|an": the first | parts
|
|
122
|
+
.replace(/(?<=[\p{L}\p{N}])[|!]+(?![\p{L}\p{N}])/gu, " ")); // "k|an|Nazia": the last | too
|
|
123
|
+
// folded as the main check folds: look-alikes, leetspeak ($$, @rmy), and | ! read as letters or as separators
|
|
124
|
+
return [letters(h), leet(letters(h)), ...readings(h).map((x) => leet(letters(x)))].some((c) => ptWords(c).some(hate)) ? s : kept;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Numeric codes, checked on the RAW handle: the leet fold that catches letter evasions destroys digits. A bare "88" is
|
|
128
|
+
* far too common in real handles (birth years) to block on its own. Also on the digits-only copy (dots, underscores,
|
|
129
|
+
* dashes, spaces and invisible characters dropped: "14.88", "14_88"). */
|
|
130
|
+
const RAW_DENY = [/1488/, /\b14\s*88\b/, /\b88\s*14\b/,
|
|
131
|
+
// A few slurs written in their own script, which the Latin fold can't reach (the PR #1831 review: Russian "pidor").
|
|
132
|
+
/пид[оа]р/, /педик/];
|
|
133
|
+
/** The worst words spelled in Cyrillic or Greek letters as those languages write them (not look-alikes, real
|
|
134
|
+
* transliterations): ниггер, нигга, гитлер, χίτλερ. Matched on the lowercase name with accents off. Not нигер (the
|
|
135
|
+
* country Niger) or Гитлин (a surname). */
|
|
136
|
+
const NATIVE_DENY = /ни+г{2,}[еэ]+р|ни+г{2,}а|гитлер|χιτλερ/;
|
|
137
|
+
const DIGITS_DENY = /1488|8814/;
|
|
138
|
+
/** Bidi overrides and isolates have no place in a name: they exist to make a name read as something else
|
|
139
|
+
* ("\u202Ereltih" draws as hitler). A game that cleans a name for drawing strips them first (cleanName). */
|
|
140
|
+
const BIDI = /[\u202A-\u202E\u2066-\u2069]/;
|
|
141
|
+
|
|
142
|
+
/** Look-alike letters folded to Latin before the deny check: Cyrillic, Greek (capitals too, mapped before lowercasing,
|
|
143
|
+
* or Η would become η and read as "n"), IPA, small capitals, dotless and barred letters, and the Cherokee capitals that
|
|
144
|
+
* pass for Latin ("hiᏆler", a "Ꮐengduck" impostor). NFKD turns full-width (hitler), maths letters (𝐡𝐢𝐭𝐥𝐞𝐫), ſ and
|
|
145
|
+
* Roman numerals into plain ones and splits accents off, so "hítler" can't lose its í. */
|
|
146
|
+
const CONFUSABLE = {
|
|
147
|
+
// Cyrillic
|
|
148
|
+
"А": "a", "В": "b", "Е": "e", "К": "k", "М": "m", "Н": "h", "О": "o", "Р": "p", "С": "c", "Т": "t", "У": "y", "Х": "x", "Ѕ": "s", "І": "i", "Ј": "j", "Ү": "y",
|
|
149
|
+
"а": "a", "в": "b", "е": "e", "к": "k", "м": "m", "н": "h", "о": "o", "р": "p", "с": "c", "т": "t", "у": "y", "х": "x", "ѕ": "s", "і": "i", "ї": "i", "ј": "j", "ԁ": "d", "ӏ": "l", "ү": "y",
|
|
150
|
+
// Greek
|
|
151
|
+
"Α": "a", "Β": "b", "Ε": "e", "Ζ": "z", "Η": "h", "Ι": "i", "Κ": "k", "Μ": "m", "Ν": "n", "Ο": "o", "Ρ": "p", "Τ": "t", "Υ": "y", "Χ": "x",
|
|
152
|
+
"α": "a", "β": "b", "ε": "e", "ζ": "z", "η": "n", "ι": "i", "κ": "k", "ν": "v", "ο": "o", "ρ": "p", "τ": "t", "υ": "u", "χ": "x", "γ": "y", "ω": "w", "μ": "u",
|
|
153
|
+
// Latin look-alikes NFKD leaves alone, and small capitals
|
|
154
|
+
"ı": "i", "ɩ": "i", "ɨ": "i", "ɑ": "a", "ɒ": "a", "ɡ": "g", "ǥ": "g", "ɢ": "g", "ł": "l", "ø": "o", "đ": "d", "ħ": "h", "ŧ": "t", "ƀ": "b", "ɍ": "r", "ʉ": "u", "ɇ": "e",
|
|
155
|
+
"ᴀ": "a", "ʙ": "b", "ᴄ": "c", "ᴅ": "d", "ᴇ": "e", "ʜ": "h", "ɪ": "i", "ᴊ": "j", "ᴋ": "k", "ʟ": "l", "ᴍ": "m", "ɴ": "n", "ᴏ": "o", "ᴘ": "p",
|
|
156
|
+
"ʀ": "r", "ꜱ": "s", "ᴛ": "t", "ᴜ": "u", "ᴠ": "v", "ᴡ": "w", "ʏ": "y", "ᴢ": "z",
|
|
157
|
+
// Cherokee capitals
|
|
158
|
+
"Ꭺ": "a", "Ᏼ": "b", "Ꮯ": "c", "Ꭼ": "e", "Ꮐ": "g", "Ꮋ": "h", "Ꮖ": "t", "Ꭻ": "j", "Ꮶ": "k", "Ꮮ": "l", "Ꮇ": "m", "Ꮎ": "o", "Ꮲ": "p", "Ꭱ": "r", "Ꮪ": "s", "Ꭲ": "t", "Ꮩ": "v", "Ꮃ": "w", "Ꮓ": "z",
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* From Unicode's confusables.txt (2026-08-06): every letter whose prototype is one Latin letter, in Latin (extended,
|
|
162
|
+
* IPA), Cyrillic, Greek, Coptic, Armenian, Cherokee and the maths alphanumerics, that NFKD and the table above didn't
|
|
163
|
+
* already fold (2026-10-20: "һitler" with Cyrillic һ reached a board). The vertical bars among them (ǀ ꟾ Ⲓ) are read as
|
|
164
|
+
* i or l with I, 1 and | (readings). A name that holds any of these is also read as it was before they were added
|
|
165
|
+
* (check), so a separator can't become a letter. names-fixture.js CONFUSABLES_ADDED lists them for the stem matrix.
|
|
166
|
+
*/
|
|
167
|
+
const CONFUSABLE_ADDED = {
|
|
168
|
+
// Latin
|
|
169
|
+
"ꭤ": "a", "Ƅ": "b", "Ꞵ": "b", "ꬲ": "e", "ꬵ": "f", "ꞙ": "f", "ƒ": "f", "ʄ": "f", "ẝ": "f", "Ꞙ": "f", "ᶃ": "g", "ƍ": "g", "ȷ": "j", "Ʝ": "j", "ꞁ": "l", "ᴑ": "o", "ꬽ": "o", "ƿ": "p", "ꭇ": "r", "ꭈ": "r", "ƽ": "s", "ꞟ": "u", "ꭎ": "u", "ꭒ": "u", "ʋ": "u", "ɯ": "w", "ꟺ": "w", "Ꭓ": "x", "ɣ": "y", "ᶌ": "y", "ỿ": "y", "ꭚ": "y", "ⱬ": "z", "Ⱬ": "z",
|
|
170
|
+
// Cyrillic
|
|
171
|
+
"Ь": "b", "ᲃ": "c", "ҽ": "e", "Ԍ": "g", "һ": "h", "Һ": "h", "ꙇ": "i", "ᲂ": "o", "ԛ": "q", "Ԛ": "q", "г": "r", "ѵ": "v", "Ѵ": "v", "ѡ": "w", "ш": "w", "ԝ": "w", "Ԝ": "w",
|
|
172
|
+
// Cherokee
|
|
173
|
+
"Ꮟ": "b", "ꮯ": "c", "Ꮷ": "d", "Ꭰ": "d", "Ᏻ": "g", "Ꮒ": "h", "ꭵ": "i", "Ꭵ": "i", "ꮁ": "r", "Ꮢ": "r", "ꮪ": "s", "Ꮥ": "s", "ꮩ": "v", "ꮃ": "w", "ꮤ": "w", "Ꮤ": "w", "Ꭹ": "y", "Ꮍ": "y", "ꮓ": "z",
|
|
174
|
+
// Coptic
|
|
175
|
+
"Ⲃ": "b", "ⲥ": "c", "Ⲥ": "c", "Ⲏ": "h", "ⲓ": "i", "Ⲕ": "k", "Ⳑ": "l", "Ⲙ": "m", "Ⲛ": "n", "ⲟ": "o", "ϭ": "o", "Ⲟ": "o", "ⲣ": "p", "ⳏ": "p", "Ⲣ": "p", "Ⳏ": "p", "ⲅ": "r", "Ⲧ": "t", "ⲽ": "w", "Ⲭ": "x", "ⲩ": "y", "Ⲩ": "y", "ⲍ": "z", "Ⲍ": "z",
|
|
176
|
+
// Greek
|
|
177
|
+
"ϲ": "c", "Ϲ": "c", "Ϝ": "f", "ϳ": "j", "Ϳ": "j", "Ϻ": "m", "σ": "o", "ϸ": "p", "ᴦ": "r",
|
|
178
|
+
// Armenian
|
|
179
|
+
"ք": "f", "ց": "g", "հ": "h", "ւ": "i", "յ": "j", "ո": "n", "ռ": "n", "օ": "o", "Օ": "o", "գ": "q", "զ": "q", "Տ": "s", "ս": "u", "Ս": "u", "ա": "w",
|
|
180
|
+
// maths alphanumerics NFKD leaves Greek (𝛔 is σ)
|
|
181
|
+
"𝟊": "f", "𝚥": "j", "𝛔": "o", "𝜎": "o", "𝝈": "o", "𝞂": "o", "𝞼": "o",
|
|
182
|
+
// ...and those whose prototype is a Latin letter the fold already reads (ԍ is ɢ, a small capital g; θ an o)
|
|
183
|
+
// Cherokee
|
|
184
|
+
"ꭺ": "a", "ᏼ": "b", "ꭰ": "d", "ꭼ": "e", "ꮐ": "g", "ᏻ": "g", "Ᏺ": "h", "ꮋ": "h", "ꭻ": "j", "ꮮ": "l", "ꮎ": "o", "ꮻ": "o", "Ꮻ": "o", "ꭴ": "o", "Ꭴ": "o", "ꮲ": "p", "ꭱ": "r", "ꮢ": "r", "Ꮏ": "t", "ꭲ": "t", "ꮜ": "u", "Ꮜ": "u", "Ꮗ": "w",
|
|
185
|
+
// Cyrillic
|
|
186
|
+
"ꚝ": "b", "Б": "b", "ҍ": "b", "Ҍ": "b", "ѣ": "b", "Ѣ": "b", "ҫ": "c", "Ҫ": "c", "ҿ": "e", "ԍ": "g", "ꚕ": "h", "Ң": "h", "ћ": "h", "Ӊ": "h", "Ӈ": "h", "ң": "h", "ӊ": "h", "ӈ": "h", "Қ": "k", "Ҟ": "k", "Ӎ": "m", "ө": "o", "ѳ": "o", "Ө": "o", "Ѳ": "o", "ғ": "r", "Ꚍ": "t", "Ҭ": "t", "ꚍ": "t", "ҭ": "t", "џ": "u", "ѽ": "w", "Ҳ": "x", "ұ": "y", "Ұ": "y", "ꙍ": "w", "𞁫": "c", "Ѽ": "w", "Ҿ": "e",
|
|
187
|
+
// Latin
|
|
188
|
+
"ɓ": "b", "ƃ": "b", "Ƃ": "b", "ȼ": "c", "ɗ": "d", "ɖ": "d", "ƌ": "d", "Ƌ": "d", "Ð": "d", "Ɖ": "d", "ᵮ": "f", "ɠ": "g", "ɦ": "h", "Ⱨ": "h", "ᵻ": "i", "ᵼ": "i", "ɉ": "j", "ɟ": "j", "Ɉ": "j", "ƙ": "k", "Ⱪ": "k", "Ꝁ": "k", "ɭ": "l", "ƚ": "l", "ɫ": "l", "ɳ": "n", "ƞ": "n", "ŋ": "n", "ɲ": "n", "Ɲ": "n", "ᵰ": "n", "ꬾ": "o", "ɵ": "o", "ꝋ": "o", "Ɵ": "o", "Ꝋ": "o", "ƥ": "p", "ᵽ": "p", "ʠ": "q", "ɽ": "r", "ɼ": "r", "ᵲ": "r", "ʂ": "s", "Ʂ": "s", "ᵴ": "s", "ƭ": "t", "Ⱦ": "t", "Ʈ": "t", "ƫ": "t", "ᵵ": "t", "ᵾ": "u", "ꝡ": "w", "ƴ": "y", "ɏ": "y", "Ɏ": "y", "ʐ": "z", "ƶ": "z", "Ƶ": "z", "ȥ": "z", "Ȥ": "z", "ᵶ": "z", "ꭓ": "x", "ꭕ": "x", "ꞷ": "w",
|
|
189
|
+
// Coptic
|
|
190
|
+
"ⲃ": "b", "ⲏ": "h", "ⳑ": "l", "ⲛ": "n", "ⲑ": "o", "Ⲑ": "o", "ⲧ": "t", "ⲭ": "x", "ⲱ": "w", "Ⳁ": "f",
|
|
191
|
+
// Armenian
|
|
192
|
+
"ղ": "n",
|
|
193
|
+
// Greek
|
|
194
|
+
"θ": "o", "ϑ": "o", "Θ": "o", "ϴ": "o", "ᴩ": "p",
|
|
195
|
+
// maths alphanumerics (theta)
|
|
196
|
+
"𝛉": "o", "𝛝": "o", "𝜃": "o", "𝜗": "o", "𝜽": "o", "𝝑": "o", "𝝷": "o", "𝞋": "o", "𝞱": "o", "𝟅": "o", "𝚯": "o", "𝚹": "o", "𝛩": "o", "𝛳": "o", "𝜣": "o", "𝜭": "o", "𝝝": "o", "𝝧": "o", "𝞗": "o", "𝞡": "o",
|
|
197
|
+
// ...the look-alike blocks of Lisu, Canadian Syllabics, Runic and Tifinagh (the #1941 review: ꓠІᏀᏀᎬᎡ, ᑎIᘜᘜᗴᖇ, ꓠꓲꓖꓖꓰꓣ
|
|
198
|
+
// spelled a whole slur outside Latin), and Greek capital Λ for L ("ΗΕΙΛ 88"). Their bars (ꓲ ᛁ ⵏ, and Hangul ㅣ) are read
|
|
199
|
+
// as i or l with I, 1 and | (BARS).
|
|
200
|
+
"ꓮ": "a", "ꓐ": "b", "ꓚ": "c", "ꓒ": "d", "ꓓ": "d", "ꓰ": "e", "ꓝ": "f", "ꓖ": "g", "ꓧ": "h", "ꓙ": "j", "ꓗ": "k", "ꓡ": "l",
|
|
201
|
+
"ꓟ": "m", "ꓠ": "n", "ꓵ": "n", "ꓳ": "o", "ꓑ": "p", "ꓣ": "r", "ꓢ": "s", "ꓔ": "t", "ꓴ": "u", "ꓦ": "v", "ꓪ": "w", "ꓫ": "x",
|
|
202
|
+
"ꓬ": "y", "ꓜ": "z",
|
|
203
|
+
"ᗅ": "a", "ᑲ": "b", "ᖯ": "b", "ᗷ": "b", "ᑳ": "b", "ᑯ": "d", "ᗞ": "d", "ᗪ": "d", "ᗴ": "e", "ᖴ": "f", "ᘜ": "g", "ᕼ": "h",
|
|
204
|
+
"ᓰ": "i", "ᒍ": "j", "ᒪ": "l", "ᗰ": "m", "ᑎ": "n", "ᑭ": "p", "ᖇ": "r", "ᑌ": "u", "ᐯ": "v", "ᘯ": "w", "ᘵ": "w", "ᗯ": "w",
|
|
205
|
+
"ᕁ": "x", "ᕽ": "x", "ᒥ": "y",
|
|
206
|
+
"ᛕ": "k", "ᛖ": "m",
|
|
207
|
+
"ⴹ": "e", "ⵊ": "l", "ⵔ": "o", "ⵁ": "o", "ⴱ": "o", "ⵕ": "q", "ⴸ": "v", "ⵝ": "x",
|
|
208
|
+
"Λ": "l",
|
|
209
|
+
};
|
|
210
|
+
Object.assign(CONFUSABLE, CONFUSABLE_ADDED);
|
|
211
|
+
|
|
212
|
+
// A capital I, 1, | or ! (or a bar of another script: ǀ ꟾ Ⲓ ꓲ ᛁ ⵏ ㅣ) can stand for i or for l ("hitIer", "HITIER", "hit1er"): every reading is checked, up
|
|
213
|
+
// to 16 of them (beyond 4 such characters, all-i and all-l).
|
|
214
|
+
const BAR_CHAR = /[I1|!\u01C0\uA7FE\u2C92\uA4F2\u16C1\u2D4F\u3163\u1175]/u; // one of BARS, without the g flag
|
|
215
|
+
const BARS = /[I1|!\u01C0\uA7FE\u2C92\uA4F2\u16C1\u2D4F\u3163\u1175]/g; // ǀ ꟾ Ⲓ ꓲ ᛁ ⵏ ㅣ (NFKC makes ㅣ U+1175)
|
|
216
|
+
function readings(name) {
|
|
217
|
+
// (look-alikes folded before NFKC, which would turn Greek Ϲ into Σ)
|
|
218
|
+
const s = String(name ?? "").replace(CONFUSABLE_RE, (ch) => CONFUSABLE[ch]).normalize("NFKC"), k = (s.match(BARS) || []).length, n = k <= 4 ? 1 << k : 2;
|
|
219
|
+
return Array.from({ length: n }, (_, c) => { let j = 0; return s.replace(BARS, () => ((k <= 4 ? (c >> j++) & 1 : c) ? "l" : "i")); });
|
|
220
|
+
}
|
|
221
|
+
/** Enclosed Latin capitals that NFKD leaves alone or wraps (parenthesized 🄐, circled 🄠, squared 🄰, negative circled 🅐,
|
|
222
|
+
* negative squared 🅰) and the regional indicator letters (🇳🇮🇬…, which draw as flags in pairs). The name is read with
|
|
223
|
+
* them as separators, as before ("n🇺i🇺g🇺g🇺e🇺r"); then each run of them (separators between allowed) is read as a-z ON
|
|
224
|
+
* ITS OWN, never joined to the letters or words beside it, so "🇰🇾 Sam" and "🇺🇸Nazia" are a flag and a name. A run of
|
|
225
|
+
* regional indicators counts only from six letters (three flags): two flags side by side (🇵🇪🇩🇴, 🇳🇮🇬🇷, 🇰🇪🇰🇮) are
|
|
226
|
+
* ordinary dual-nationality decoration and spell a stem by accident far more often than on purpose. */
|
|
227
|
+
const ENCLOSED_RUN = /[\u{1F110}-\u{1F189}](?:[\s._-]*[\u{1F110}-\u{1F189}])*/gu;
|
|
228
|
+
const REGIONAL_RUN = /[\u{1F1E6}-\u{1F1FF}](?:[\s._-]*[\u{1F1E6}-\u{1F1FF}])*/gu;
|
|
229
|
+
/** The ISO 3166-1 codes, so one real flag beside an allowed word reads as a flag. */
|
|
230
|
+
const FLAGS = new Set(("ad ae af ag ai al am ao aq ar as at au aw ax az ba bb bd be bf bg bh bi bj bl bm bn bo bq br bs bt bv bw by " +
|
|
231
|
+
"bz ca cc cd cf cg ch ci ck cl cm cn co cr cu cv cw cx cy cz de dj dk dm do dz ec ee eg eh er es et fi fj fk " +
|
|
232
|
+
"fm fo fr ga gb gd ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il im in io iq ir " +
|
|
233
|
+
"is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc li lk lr ls lt lu lv ly ma mc md me mf mg mh mk " +
|
|
234
|
+
"ml mm mn mo mp mq mr ms mt mu mv mw mx my mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl pm " +
|
|
235
|
+
"pn pr ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sj sk sl sm sn so sr ss st sv sx sy sz tc td tf " +
|
|
236
|
+
"tg th tj tk tl tm tn to tr tt tv tw tz ua ug um us uy uz va vc ve vg vi vn vu wf ws ye yt za zm zw").split(" "));
|
|
237
|
+
const ENCLOSED = /[\u{1F110}-\u{1F189}\u{1F1E6}-\u{1F1FF}]/gu;
|
|
238
|
+
const unEnclose = (s) => s.replace(ENCLOSED, (ch) => {
|
|
239
|
+
const cp = ch.codePointAt(0), base = cp >= 0x1F1E6 ? 0x1F1E6 : cp >= 0x1F170 ? 0x1F170 : cp >= 0x1F150 ? 0x1F150 : cp >= 0x1F130 ? 0x1F130 : 0x1F110;
|
|
240
|
+
return cp - base < 26 ? String.fromCharCode(97 + cp - base) : ch;
|
|
241
|
+
});
|
|
242
|
+
/** Digits of any script as 0-9 (NFKC handles full-width, maths, circled and superscript ones; this takes the rest:
|
|
243
|
+
* Thai ๘, Devanagari ८, Arabic-Indic ٨). */
|
|
244
|
+
/** A word of Roman numerals in letters as the digits it spells, numeral by numeral (longest first, up to 89): "viiiviii"
|
|
245
|
+
* is 88, "xiv" 14, "lxxxviii" 88. "" when it isn't one. */
|
|
246
|
+
const ROMAN = Object.fromEntries(Array.from({ length: 89 }, (_, k) => {
|
|
247
|
+
const n = k + 1, t = ["", "x", "xx", "xxx", "xl", "l", "lx", "lxx", "lxxx"][Math.floor(n / 10)], u = ["", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix"][n % 10];
|
|
248
|
+
return [t + u, String(n)];
|
|
249
|
+
}));
|
|
250
|
+
function romanWord(w) {
|
|
251
|
+
let out = "";
|
|
252
|
+
for (let i = 0; i < w.length;) {
|
|
253
|
+
let j = Math.min(w.length, i + 8);
|
|
254
|
+
while (j > i && !ROMAN[w.slice(i, j)]) j--;
|
|
255
|
+
if (j === i) return "";
|
|
256
|
+
out += ROMAN[w.slice(i, j)];
|
|
257
|
+
i = j;
|
|
258
|
+
}
|
|
259
|
+
return out;
|
|
260
|
+
}
|
|
261
|
+
/** Roman numeral characters as digits, one each (ⅧⅧ is 88), before NFKC spells them out as letters. */
|
|
262
|
+
const romanDigits = (s) => s.replace(/[\u2160-\u216B\u2170-\u217B]/g, (ch) => String((ch.charCodeAt(0) & 0xF) + 1));
|
|
263
|
+
const asciiDigits = (s) => romanDigits(s).normalize("NFKC").replace(/(?![0-9])\p{Nd}/gu, (ch) => {
|
|
264
|
+
let cp = ch.codePointAt(0), k = 0;
|
|
265
|
+
while (k < 9 && /\p{Nd}/u.test(String.fromCodePoint(cp - 1))) { cp--; k++; }
|
|
266
|
+
return String(k);
|
|
267
|
+
});
|
|
268
|
+
/** Accents and format characters off, look-alikes folded, lowercased; separators and digits still in place. */
|
|
269
|
+
const CONFUSABLE_RE = new RegExp(`[${Object.keys(CONFUSABLE).join("")}]`, "gu"), LETTERS = new Map();
|
|
270
|
+
/** Look-alikes whose capital looks like something else: Σ lowercases to σ (an o), Г to г and Ғ to ғ (an r), but Σ, Г
|
|
271
|
+
* and Ғ pass for none of them (Г and Ғ have Greek Γ for their prototype). After lowercasing they stay letters of their
|
|
272
|
+
* own script, as before. */
|
|
273
|
+
const LOWER_OF_UNLIKE = new Set(["σ", "г", "ғ"]);
|
|
274
|
+
const letters = (name) => {
|
|
275
|
+
const s = String(name ?? "");
|
|
276
|
+
let out = LETTERS.get(s);
|
|
277
|
+
if (out === undefined) {
|
|
278
|
+
// folded before NFKD as well as after: NFKD turns some look-alikes into other letters (Greek Ϲ into Σ, then σ "o")
|
|
279
|
+
out = s.replace(CONFUSABLE_RE, (ch) => CONFUSABLE[ch]).normalize("NFKD").replace(/[\p{M}\p{Cf}]/gu, "").replace(CONFUSABLE_RE, (ch) => CONFUSABLE[ch])
|
|
280
|
+
.toLowerCase().replace(CONFUSABLE_RE, (ch) => (LOWER_OF_UNLIKE.has(ch) ? ch : CONFUSABLE[ch]));
|
|
281
|
+
if (LETTERS.size >= 20000) LETTERS.clear(); // one name's readings and copies ask for the same folds many times
|
|
282
|
+
LETTERS.set(s, out);
|
|
283
|
+
}
|
|
284
|
+
return out;
|
|
285
|
+
};
|
|
286
|
+
const leet = (s) => s.replace(/3/g, "e").replace(/0/g, "o").replace(/[69]/g, "g")
|
|
287
|
+
.replace(/5|\$/g, "s").replace(/4|@/g, "a").replace(/7/g, "t");
|
|
288
|
+
/** A name folded for comparing identities (a viewer named like the streamer): accents, width, case and look-alike
|
|
289
|
+
* letters folded; separators and digits kept. The games' impostor checks build on it. */
|
|
290
|
+
export const foldLetters = letters;
|
|
291
|
+
|
|
292
|
+
/* ---- pt-BR name floor: begin ----
|
|
293
|
+
* The entries are prototypes/live-chat/review/pt-BR-name-filter-draft.md, which the Brazilian reviewer greenlit as
|
|
294
|
+
* drafted (2026-10-19), and the Spanish ones (ES_*) are review/es-name-filter-draft.md, shipped without a native
|
|
295
|
+
* reviewer on the owner's word (2026-10-19: "let the players tell us what to adjust"). ptUnsafe() is given
|
|
296
|
+
* de-obfuscated copies of the name: lowercase, accents and look-alike letters folded (ñ reads as n, ü as u), one copy
|
|
297
|
+
* with leetspeak folded and one with digits left as separators. Anything that isn't a-z is a separator. A letter in
|
|
298
|
+
* an entry matches a run of it ("puuuta", "viiiado"), and a run of single letters reads as one word ("p.u.t.a",
|
|
299
|
+
* "f d p"). */
|
|
300
|
+
const PT_LOOSE = (w) => w.replace(/[a-z]/g, "$&+");
|
|
301
|
+
/** trecho: inside a word, or from the start of a word across separators ("v.i.a.d.o", "filho_da_puta"). Never from
|
|
302
|
+
* the middle of one word into the next, so two names can't spell one ("Lívia do Carmo" isn't viado). */
|
|
303
|
+
const PT_TRECHO = [
|
|
304
|
+
// viado, not enviado, aliviado, desviado, transviado, abreviado, aviado, extraviado, ataviado, esgrouviado or
|
|
305
|
+
// aviador; nor Spanish obviado, antuviado, engaviado, nerviado, or silviadominguez as one lowercase login (es §3)
|
|
306
|
+
/(?<!li|xi|es|ns|en|re|lu|nu|ta|ra|sa|ea|ob|tu|ga|er|il|ou|^a)v+i+a+d+o+(?!r)/, "boiola", "baitola", "sapatao",
|
|
307
|
+
"fanchona", "traveco", "crioulo", "aleijado", "debilmental",
|
|
308
|
+
// boceta, bocetas, bocetão, not Spanish bocetar, bocetado, bocetando, bocetaba, bocetamos, bocetaste (to sketch)
|
|
309
|
+
"vagabunda", "buceta", /b+o+c+e+t+a+(?![rdbnm]|s[et])/, "xoxota", "xereca", "piroca", "caralho", "punheta", "siririca",
|
|
310
|
+
"boquete",
|
|
311
|
+
/f+o+de+r+(?!aro)/, "fodid", "fodase", "novinha", "ninfeta", // foder, not cannon_fodder or Foderaro
|
|
312
|
+
/a+r+r+o+m+b+a+d+o+(?!r)/, "cuzao", "filhodaputa", "vaisematar", "voutematar", // arrombado, not arrombador (a burglar)
|
|
313
|
+
/a+n+a+u+e+(?![dnhm])/, // anauê, not Ana Ueda, Ana Ueno, Ana Uehara
|
|
314
|
+
"tiktokoficial", "twitchoficial", "youtubeoficial", "suportetiktok", "suportetwitch", "suporteyoutube",
|
|
315
|
+
"equipetiktok", "equipetwitch", "equipeyoutube", "admtiktok", "admtwitch", "pixgratis", "ganhepix", "sorteiobot",
|
|
316
|
+
"cliqueaqui", "linknabio", "bitsgratis", "subsgratis",
|
|
317
|
+
].map((r) => (typeof r === "string" ? PT_LOOSE(r) : r.source));
|
|
318
|
+
/** trecho, but only from the start of a word: "se mata" and "te mato" sit inside José Mata and Dante Matos. */
|
|
319
|
+
const PT_TRECHO_START = ["semata", "temato", "seenforca"].map(PT_LOOSE);
|
|
320
|
+
/** palavra: a whole word between separators (_ . - spaces digits), plural -s too: puta_123 and putas, not disputa. */
|
|
321
|
+
const PT_PALAVRA = ["bicha", "mulherzinha", "macaco", "macaca", "ticao", "mongol", "puta", "putinha", "rapariga",
|
|
322
|
+
"krl", "crl", "gostosa", "safada", "fdp", "vsf", "vtnc", "tnc", "pqp", "corno", "suicida", "integralista"];
|
|
323
|
+
/** palavra without the plural: porra and pica, not Porras (a Spanish surname) or picas (spades, in Spanish cards). */
|
|
324
|
+
const PT_PALAVRA_ONE = ["porra", "pica"];
|
|
325
|
+
/** The Spanish entries (es-name-filter-draft.md §1, §5), as drafted except: caraverga and careverga not before an r
|
|
326
|
+
* (Cara Vergara), and the -es plurals of the palavra words that end in a consonant (cabrones, culones, mamones). */
|
|
327
|
+
const ES_TRECHO = [
|
|
328
|
+
"machorra", "marimacho", "sidoso", "sidosa", /s+u+d+a+c+a+(?!o)/, "mongolic", "mogolic", "subnormal",
|
|
329
|
+
"hijodeputa", "hijadeputa", "hijoputa", "hijaputa", "hijueputa", "jueputa", "granputa", "putamadre",
|
|
330
|
+
"chingar", "chingad", "chingatumadre", "vergud", "chupaverga", "chupapija", "chupapolla", "poronga", "singao",
|
|
331
|
+
"mamabicho", /(?<!ja)m+i+e+r+d+a+/, "joder", /(?<![ais])f+o+l+l+a+r+/, "mamaguevo", "mamahuevo", "mamaguebo",
|
|
332
|
+
"pajillero", "culiao", "culiad", "malparid", "malnacid", /c+a+r+[ae]+v+e+r+g+a+(?!r)/, "carechimba", "caremonda", "gilipollas",
|
|
333
|
+
"suicidate", "ahorcate", "tevoyamatar", "voyamatarte", "cortatelasvenas",
|
|
334
|
+
"pederast", "menorcit", "vendocp", "cpgratis", "poderblanco", "orgulloblanco",
|
|
335
|
+
/r+a+z+a+a+r+i+a+(?!s)/, // raza aria, not Raza Arias
|
|
336
|
+
// conchatumadre, conchetumare, conchesumadre, concha de tu madre; coño de tu madre, coñoetumadre
|
|
337
|
+
/c+o+n+c+h+[aeu]+(?:d+e+)?[st]+u+m+a+(?:d+)?r+e+/, /c+o+n+o+(?:d+)?e+t+u+m+a+(?:d+)?r+e+/,
|
|
338
|
+
...["soporte", "equipo", "oficial", "moderador", "admin", "administrador", "ayuda"]
|
|
339
|
+
.flatMap((w) => ["tiktok", "twitch", "youtube"].map((p) => w + p)),
|
|
340
|
+
"tiktoksoporte", "twitchsoporte", "youtubesoporte", "tiktokayuda", "twitchayuda", "youtubeayuda", "sorteobot",
|
|
341
|
+
"clicaqui", "clickaqui", "hazclic", "linkenbio", "linkenlabio", "enlaceenbio", "monedasgratis", "seguidoresgratis",
|
|
342
|
+
"nitrogratis",
|
|
343
|
+
].map((r) => (typeof r === "string" ? PT_LOOSE(r) : r.source));
|
|
344
|
+
// (sudaca not before o: pt sudação, transudação; mierda not after ja: jamerdar; follar not after a, i or s:
|
|
345
|
+
// afollar, emperifollar, cachifollar, desfollar)
|
|
346
|
+
/** te mataré, from the start of a word only (temática passes; the unlikely name Tema Tarea doesn't). */
|
|
347
|
+
const ES_TRECHO_START = ["tematare"].map(PT_LOOSE);
|
|
348
|
+
/** palavra. Never trecho: verga (Vergara), culo (artículo, cálculo), pija (pijama), polla (pollo), teta (tetera),
|
|
349
|
+
* pene (Penélope), puto (cómputo, diputado), maricon (Mari Contreras), jodido (Jodi Díaz), negrata (Negra Tamara), matate (Mata Teresa).
|
|
350
|
+
* puto, pene and mamon don't take a doubled consonant (putto, penne, Mammon). */
|
|
351
|
+
const ES_PALAVRA = ["maricon", "maricones", "mariconazo", "marica", "marika", "marico", "joto", /p+u+to+/, "trolo",
|
|
352
|
+
"maraco", "fleto", "pirobo", "playo", "tortillera", "bollera", "travelo", "negrata", "veneco", "veneca", "moraco", "mayate",
|
|
353
|
+
"retrasado", "retrasada", "tarado", "tarada", "putita", "putona", "hdp", "ptm", "ctm", "csm", "conchudo", "conchuda",
|
|
354
|
+
"chinga", "verga", "chupala", "chupamela", "pija", "pijudo", "pinga", "polla", "singar", /p+e+ne+/, "teta", "tetona",
|
|
355
|
+
"culo", "culon", "culones", "culona", "ojete", "jodido", "jodida", "jodete", "mamada", /m+a+mo+n+/, "mamones", "mmgv",
|
|
356
|
+
"pajero", "panocha", "chucha", "zorra", "perra", "guarra", "golfa", "prostituta", "violador", "violadora", "puneta",
|
|
357
|
+
"ql", "cagon", "cagones", "cagona", "gonorrea", "pendejo", "pendeja", "culero", "culera", "cabron", "cabrones",
|
|
358
|
+
"cabrona", "boludo", "boluda", "pelotudo", "pelotuda", "cojudo", "aweonao", "ahueonao", "sorete", "cornudo", "cornuda",
|
|
359
|
+
"matate", "muerete", "falangista"];
|
|
360
|
+
const PT_INSIDE_RE = new RegExp([...PT_TRECHO, ...ES_TRECHO].join("|"));
|
|
361
|
+
const PT_FROM_START_RE = new RegExp(`^(?:${[...PT_TRECHO, ...PT_TRECHO_START, ...ES_TRECHO, ...ES_TRECHO_START].join("|")})`);
|
|
362
|
+
const PT_PALAVRA_RE = new RegExp(`^(?:${[...PT_PALAVRA, ...ES_PALAVRA, ...EN_PALAVRA].map((r) => (typeof r === "string" ? PT_LOOSE(r) : r.source))
|
|
363
|
+
.join("|")})s*$|^(?:${PT_PALAVRA_ONE.map(PT_LOOSE).join("|")})$`);
|
|
364
|
+
/** kkk is Brazilian laughter (kkkk, joao_kkk). It is the Klan as the whole name (kkk, k.k.k, KKK_88) or beside a
|
|
365
|
+
* Klan word (kkk_member, the_kkk, kkkklan). */
|
|
366
|
+
const PT_KLAN_AFTER = /^(?:klan|klux|members?|wizards?|knights?|rally|army|nation|hood)$/, PT_KLAN_BEFORE = /^(?:the|grand|white|imperial)$/;
|
|
367
|
+
const PT_KLAN_JOINED = /(?<!k)kkk(?:klan|klux|member|wizard|knight|rally|army|nation|hood)|(?:the|grand|white|imperial)kkk(?!k)/;
|
|
368
|
+
/** camelCase humps are word breaks too, so a Twitch display name reads as its parts: "SilviaDourado" isn't viado,
|
|
369
|
+
* "FilhoDaPuta" still is. Applied to the name before it is folded into copies. */
|
|
370
|
+
const ptHumps = (name) => String(name ?? "").replace(/(\p{Ll})(\p{Lu})/gu, "$1 $2");
|
|
371
|
+
function ptWords(copy) {
|
|
372
|
+
const out = [];
|
|
373
|
+
let single = false;
|
|
374
|
+
for (const w of String(copy).replace(/[^a-z]+/g, " ").trim().split(" ")) {
|
|
375
|
+
if (!w) continue;
|
|
376
|
+
if (w.length === 1 && single) out[out.length - 1] += w; // a run of single letters is one spelled-out word
|
|
377
|
+
else out.push(w);
|
|
378
|
+
single = w.length === 1;
|
|
379
|
+
}
|
|
380
|
+
return out;
|
|
381
|
+
}
|
|
382
|
+
function ptUnsafe(copies) {
|
|
383
|
+
for (const copy of copies) {
|
|
384
|
+
const words = ptWords(copy), joined = words.join("");
|
|
385
|
+
if (!joined) continue;
|
|
386
|
+
if (words.some((w) => PT_INSIDE_RE.test(w))) return true;
|
|
387
|
+
// from each word's start, through the words after it (a lookbehind sees nothing of the word before)
|
|
388
|
+
for (let i = 0, at = 0; i < words.length; at += words[i++].length) if (PT_FROM_START_RE.test(joined.slice(at))) return true;
|
|
389
|
+
if (words.some((w, i) => PT_PALAVRA_RE.test(w) && !(/^p+i+c+a+$/.test(w) && /^p+a+u+$/.test(words[i + 1] || "")))) return true; // pica-pau, the woodpecker
|
|
390
|
+
if (joined === "kkk" || PT_KLAN_JOINED.test(joined)) return true;
|
|
391
|
+
if (words.some((w, i) => w === "kkk" && (PT_KLAN_AFTER.test(words[i + 1] || "") || PT_KLAN_BEFORE.test(words[i - 1] || "")))) return true;
|
|
392
|
+
}
|
|
393
|
+
return false;
|
|
394
|
+
}
|
|
395
|
+
/** The English-era rules (each family's NAME_DENY) ran on the name with every separator stripped, so one could start
|
|
396
|
+
* inside a word and run on into the next: "Esqueço o nome" read as esque-coon-ome, "Diego Okada" as die-gook-ada.
|
|
397
|
+
* A hit now counts where a trecho's does, inside one word or from the start of a word across separators
|
|
398
|
+
* ("coonhunter", "c.o.o.n", "nig.ger"), and where three or more of its letters sit in the word it starts in
|
|
399
|
+
* ("thenig ger"): every collision the word lists turned up was the last one or two letters of a word (2026-10-19).
|
|
400
|
+
* Lookarounds still see the whole joined name, as before, so nothing new is blocked. Digits and non-Latin letters stay inside their word (they used to vanish), and `humped` is the same copy
|
|
401
|
+
* with camelCase humps as breaks, whose word starts count too ("MyTikTokAdmin"). `wild`: a non-Latin letter in a
|
|
402
|
+
* Latin name is a "?", any one letter, once per hit (Rip Night's old looseIncludes); regex rules see the name without
|
|
403
|
+
* it. SPACED_DENY is matched another way, so it sets ES_LEGACY_OK's words aside (ptAside). */
|
|
404
|
+
const PT_STICKY = new Map();
|
|
405
|
+
/** -ar verb endings, Spanish and Portuguese, and their participles (ES_ADO: not for retard, so retardado stays blocked). */
|
|
406
|
+
const ES_AR = "(?:a|as|an|amos|ais|ai|am|e|es|en|em|emos|eis|ei|o|os|ou|ar|aba|abas|aban|abamos|ava|avas|avam|avamos|aveis" +
|
|
407
|
+
"|ara|aras|aran|aram|aramos|are|ares|aren|arem|aremos|aria|arias|arian|ariam|ariamos|aron|aste|astes|asteis|ase|ases" +
|
|
408
|
+
"|asen|asemos|asse|asses|assem|assemos|asseis|ando|andose|andol[ao]s?|andoles?|andome|andote|ardes|arse|arla|arlas" +
|
|
409
|
+
"|arlo|arlos|arle|arles|arme|arte|arnos|arao|arei|areis|arieis|armos)";
|
|
410
|
+
const ES_ADO = "(?:ado|ada|ados|adas)";
|
|
411
|
+
/** Innocent whole words (folded, a-z) that hold an English-era stem: a hit of that stem lying wholly inside one of
|
|
412
|
+
* them doesn't count. Only that stem: another rule's hit in the same word still does. From the Spanish draft's §3
|
|
413
|
+
* and the Spanish, Portuguese and English word lists and name pairs (2026-10-19). Kike and a bare Paki stay blocked:
|
|
414
|
+
* the slur and the nickname are spelled the same. */
|
|
415
|
+
const ES_LEGACY_OK = Object.entries({
|
|
416
|
+
// bípedo, cuadrúpedo, palmípedo, rompedor, hospedo, pedología, pedorro (qué pedo: NAME_DENY's lookbehind)
|
|
417
|
+
pedo: ["(?:bi|cuadru|palmi|pinni|cirri|veloci|soli|fisi|ali|paralelepi)pedos?", "(?:cor)?rompedor(?:a|es|as)?", "hospedou?",
|
|
418
|
+
"encespedo", "pedolog(?:ia|ias|ica|icas|ico|icos|ic|ical|ies|ist|ists|y)", "pedona(?:l|is|les)",
|
|
419
|
+
"pedorr(?:o|a|os|as|era|eras|ero|eros|eta|etas)", `pedorre(?:${ES_AR}|${ES_ADO})`],
|
|
420
|
+
// denigrar (and English denigrate), nigromante, organigrama
|
|
421
|
+
nigr: [`denigr(?:${ES_AR}|${ES_ADO}|ante|antes|ativ[oa]s?|atori[oa]s?|acion|aciones|acao|acoes|ate|ated|ates|ating` +
|
|
422
|
+
"|ation|ations|ative|ator|ators|atory)",
|
|
423
|
+
"nigroman(?:cia|cias|te|tes|tico|tica|ticos|ticas)", "(?:orga|marco)nigramas?"],
|
|
424
|
+
// conspicuo, perspicuo (and English conspicuous), espícula, espichar, aspic, spiccato
|
|
425
|
+
spic: ["(?:in)?(?:con|per|tran)spicu(?:o|a|os|as|idad|idades|idade|ous|ously|ousness|ity|ities)",
|
|
426
|
+
"e?spicul(?:a|as|ae|ar|ation|ations|e|es|um)", `d?espich(?:${ES_AR}|${ES_ADO}|adela|adelas|el)`, `despic${ES_AR}`,
|
|
427
|
+
"aspics?", "spiccatos?"],
|
|
428
|
+
// retardo, retardar's other forms, retardante (and English retardant), sobretarde; not retard, retarded, retardado
|
|
429
|
+
retard: [`retard(?:${ES_AR}|ante|antes|ador|adora|adores|adoras|acion|aciones|acao|acoes|amento|amentos|amiento` +
|
|
430
|
+
"|amientos|ant|ants|ance|ation|ations)",
|
|
431
|
+
"(?:acarr|afr|arr|corr|decr|desclor|embarr|excr|fr|gr|interpr|marr|xer)etardes", "sobretardes?"],
|
|
432
|
+
paki: ["pakit[oa]s?"], // Pakito, Pakita (Francisco, Francisca)
|
|
433
|
+
adolf: ["adolf(?:it[oa]|in[oa])s?"], // Adolfito, Adolfina
|
|
434
|
+
rapist: ["trapist[ao]s?"], // trapista (Trappist); rapista (a barber, archaic) stays blocked
|
|
435
|
+
hitl: ["xochitls?", "hitless"], // Xóchitl, a common Mexican name; hitless (baseball)
|
|
436
|
+
}).map(([stem, words]) => [stem, new RegExp(`^(?:${words.join("|")})$`)]);
|
|
437
|
+
const ES_OK = new Map(ES_LEGACY_OK);
|
|
438
|
+
/** For the rules matched some other way (SPACED_DENY): the name with each such stem blanked inside
|
|
439
|
+
* the innocent words that hold it ("bípedo" reads "bi ", "PakitoGamer" " toGamer"), camelCase humps read as words. */
|
|
440
|
+
function ptAside(name) {
|
|
441
|
+
const blank = (p) => {
|
|
442
|
+
let f = p.normalize("NFKD").replace(/[\p{M}\p{Cf}]/gu, "").toLowerCase(), hit = false;
|
|
443
|
+
for (const [stem, re] of ES_LEGACY_OK) if (re.test(f)) { f = f.split(stem).join(" "); hit = true; }
|
|
444
|
+
return hit ? f : p;
|
|
445
|
+
};
|
|
446
|
+
return String(name ?? "").replace(/[\p{L}\p{M}\p{Cf}]+/gu, (t) => {
|
|
447
|
+
const b = blank(t);
|
|
448
|
+
return b !== t ? b : ptHumps(t).split(" ").map(blank).join("");
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
function ptShape(copy, wild) {
|
|
452
|
+
const s = String(copy ?? ""), latin = /[a-z]/.test(s), starts = new Set(), end = [], spans = [];
|
|
453
|
+
const words = s.replace(/[^a-z]/gu, (ch) => (/\p{L}/u.test(ch) ? (wild && latin ? "?" : "") : /\p{N}/u.test(ch) ? "" : " "))
|
|
454
|
+
.split(" ").filter(Boolean);
|
|
455
|
+
for (let i = 0, at = 0; i < words.length; at += words[i++].length) {
|
|
456
|
+
starts.add(at);
|
|
457
|
+
spans.push([at, at + words[i].length, words[i]]);
|
|
458
|
+
for (let j = 0; j < words[i].length; j++) end[at + j] = at + words[i].length;
|
|
459
|
+
}
|
|
460
|
+
return { joined: words.join(""), starts, end, spans };
|
|
461
|
+
}
|
|
462
|
+
function ptLegacyUnsafe(rules, copy, humped = copy, wild = false) {
|
|
463
|
+
// most names hit no rule at all, joined up as they used to be: only the ones that do are looked at word by word
|
|
464
|
+
const bare = String(copy ?? "").replace(/[^a-z]/g, "");
|
|
465
|
+
// (with one "?" standing in, a rule's first half or its second half is still there, letter for letter)
|
|
466
|
+
const odd = wild && bare && /(?![a-z])\p{L}/u.test(copy);
|
|
467
|
+
const half = (r) => { const h = r.length >> 1; return bare.includes(r.slice(0, h)) || bare.includes(r.slice(h)); };
|
|
468
|
+
const hits = rules.filter((rule) => (typeof rule === "string" ? bare.includes(rule) || (odd && half(rule)) : rule.test(bare)));
|
|
469
|
+
if (!hits.length) return false;
|
|
470
|
+
const shapes = [wild, false].map((w) => {
|
|
471
|
+
const a = ptShape(copy, w), b = ptShape(humped, w);
|
|
472
|
+
if (b.joined === a.joined) { for (const at of b.starts) a.starts.add(at); a.spans.push(...b.spans); }
|
|
473
|
+
return a;
|
|
474
|
+
});
|
|
475
|
+
// ...and not where the stem sits inside an innocent word that holds it (ES_LEGACY_OK)
|
|
476
|
+
const innocent = ({ spans }, i, text) => ES_OK.has(text) && spans.some(([s, e, w]) => s <= i && i + text.length <= e && ES_OK.get(text).test(w));
|
|
477
|
+
// ...or where the hit takes in two or more single letters spelled out ("xXn.i.g.g.e.rXx", Delve's reading)
|
|
478
|
+
const spelled = ({ spans }, i, n) => new Set(spans.filter(([s, e]) => e - s === 1 && s >= i && e <= i + n).map(([s]) => s)).size >= 2;
|
|
479
|
+
const fits = (sh, i, n, text) => (sh.starts.has(i) || i + n <= sh.end[i] || sh.end[i] - i >= 3 || spelled(sh, i, n)) && !innocent(sh, i, text);
|
|
480
|
+
return hits.some((rule) => {
|
|
481
|
+
if (typeof rule === "string") {
|
|
482
|
+
const sh = shapes[0], s = sh.joined;
|
|
483
|
+
for (let i = 0; i + rule.length <= s.length; i++) {
|
|
484
|
+
let wilds = 0, ok = true;
|
|
485
|
+
for (let j = 0; j < rule.length && ok; j++) if (s[i + j] === "?") wilds++; else ok = s[i + j] === rule[j];
|
|
486
|
+
if (ok && wilds <= 1 && fits(sh, i, rule.length, s.slice(i, i + rule.length))) return true;
|
|
487
|
+
}
|
|
488
|
+
return false;
|
|
489
|
+
}
|
|
490
|
+
let re = PT_STICKY.get(rule);
|
|
491
|
+
if (!re) PT_STICKY.set(rule, (re = new RegExp(rule.source, rule.flags.replace(/[gy]/g, "") + "y")));
|
|
492
|
+
const sh = shapes[1];
|
|
493
|
+
for (let i = 0; i < sh.joined.length; i++) {
|
|
494
|
+
re.lastIndex = i;
|
|
495
|
+
const m = re.exec(sh.joined);
|
|
496
|
+
if (m && fits(sh, i, m[0].length, m[0])) return true;
|
|
497
|
+
}
|
|
498
|
+
return false;
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
/* ---- pt-BR name floor: end ---- */
|
|
502
|
+
|
|
503
|
+
/** `hay` contains `needle`, where a "?" in hay matches any one letter, at most once per match. */
|
|
504
|
+
export function looseIncludes(hay, needle) {
|
|
505
|
+
if (!needle) return false;
|
|
506
|
+
if (hay.includes(needle)) return true;
|
|
507
|
+
if (!hay.includes("?")) return false;
|
|
508
|
+
for (let i = 0; i + needle.length <= hay.length; i++) {
|
|
509
|
+
let wild = 0, ok = true;
|
|
510
|
+
for (let j = 0; j < needle.length && ok; j++) { const c = hay[i + j]; if (c === "?") wild++; else if (c !== needle[j]) ok = false; }
|
|
511
|
+
if (ok && wild <= 1) return true;
|
|
512
|
+
}
|
|
513
|
+
return false;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Whether a viewer name may reach the stream.
|
|
518
|
+
* Answers are remembered (the last few thousand names): boards resolve names at draw time, every frame, and a full
|
|
519
|
+
* check is tens of microseconds.
|
|
520
|
+
*/
|
|
521
|
+
const SEEN = new Map();
|
|
522
|
+
export function nameIsSafe(name) {
|
|
523
|
+
const s = String(name ?? "");
|
|
524
|
+
let ok = SEEN.get(s);
|
|
525
|
+
if (ok === undefined) {
|
|
526
|
+
if (SEEN.size >= 5000) SEEN.clear();
|
|
527
|
+
SEEN.set(s, (ok = check(s)));
|
|
528
|
+
}
|
|
529
|
+
return ok;
|
|
530
|
+
}
|
|
531
|
+
/** Read across every separator, but only as the whole word: the slur split anywhere ("an.igger", "Dan_igger", which Delve's
|
|
532
|
+
* old word-gap reading caught). A stem never is ("Jan Igreja" holds nigr, "Toni Grande" too). */
|
|
533
|
+
const WHOLE_ACROSS = /n+i+g+g+(?:e+r+|a+)/;
|
|
534
|
+
/** The scripts a letter can come from, for strictWild. */
|
|
535
|
+
const SCRIPT_RES = ["Latin", "Cyrillic", "Greek", "Armenian", "Cherokee", "Coptic", "Lisu", "Canadian_Aboriginal", "Runic", "Tifinagh",
|
|
536
|
+
"Hangul", "Han", "Hiragana", "Katakana", "Arabic", "Hebrew", "Thai", "Georgian", "Devanagari", "Ethiopic"].map((n) => [n, new RegExp(`\\p{Script=${n}}`, "u")]);
|
|
537
|
+
const SCRIPT_OF = new Map();
|
|
538
|
+
const scriptOf = (ch) => {
|
|
539
|
+
let sc = SCRIPT_OF.get(ch);
|
|
540
|
+
if (sc === undefined) SCRIPT_OF.set(ch, (sc = (SCRIPT_RES.find(([, re]) => re.test(ch)) || ["Other"])[0]));
|
|
541
|
+
return sc;
|
|
542
|
+
};
|
|
543
|
+
/** The name for the strict check's "?" reading: each word (between separators) wholly in one script other than Latin
|
|
544
|
+
* has its unknown letters dropped instead of read as "?"; words with a Latin letter or of mixed scripts keep them. */
|
|
545
|
+
function strictWild(s) {
|
|
546
|
+
if (!/(?=\p{L})\P{Script=Latin}/u.test(s)) return s;
|
|
547
|
+
return s.replace(/[\p{L}\p{M}]+/gu, (w) => {
|
|
548
|
+
if (!/(?![a-z])\p{L}/u.test(letters(w))) return w; // no unknown letter: nothing to drop
|
|
549
|
+
const ls = [...w.normalize("NFKC")].filter((ch) => /\p{L}/u.test(ch));
|
|
550
|
+
const scripts = new Set(ls.map(scriptOf));
|
|
551
|
+
if (scripts.size !== 1 || scripts.has("Latin")) return w;
|
|
552
|
+
return [...w].filter((ch) => !/\p{L}/u.test(ch) || /^[a-z]+$/.test(letters(ch)) || BAR_CHAR.test(ch)).join("");
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
/** A letter that isn't a-z (after the fold): a non-Latin one, which the wild and plain readings treat differently. */
|
|
556
|
+
const NON_LATIN = /(?![a-z])\p{L}/u;
|
|
557
|
+
/** Signs that are hate symbols on their own: the swastika (卐 卍, the Tibetan ones) and the SS runes (ᛋᛋ, ϟϟ). */
|
|
558
|
+
const HATE_SYMBOLS = /[\u5350\u534D\u0FD5-\u0FD8]|\u16CB[\s._-]*\u16CB|\u03DF[\s._-]*\u03DF/u;
|
|
559
|
+
/** Longer than any platform's display name (Twitch 25, TikTok nicknames about 30): a placeholder, and no 200-character
|
|
560
|
+
* name costs the board milliseconds. */
|
|
561
|
+
const MAX_CHECKED = 64;
|
|
562
|
+
/** A name of nothing anyone can see (2026-10-21): spaces of every width (NBSP, ideographic), zero-width and other format
|
|
563
|
+
* characters (ZWSP, ZWJ, word joiner, BOM, soft hyphen, tags), control characters, combining marks with no letter
|
|
564
|
+
* under them (variation selectors, the grapheme joiner), the Hangul fillers (U+3164, U+115F, U+1160, half-width
|
|
565
|
+
* U+FFA0), the braille blank (U+2800) and the musical null notehead (U+1D159). A blank name tag or a blank "FIRST!" on the
|
|
566
|
+
* stream is no name at all, and a way round a ban list: hidden, so the game shows its placeholder. Only a name of
|
|
567
|
+
* nothing else: blanks around or inside a real name don't hide it ("\u3164maya\u3164" shows). The empty string
|
|
568
|
+
* is left as it was (callers pass "" for "no name yet"). */
|
|
569
|
+
const BLANK_ONLY = /^[\s\p{Cc}\p{Cf}\p{M}\p{Z}\u115F\u1160\u3164\uFFA0\u2800\u{1D159}]+$/u;
|
|
570
|
+
function check(s) {
|
|
571
|
+
const n = s.normalize("NFKC");
|
|
572
|
+
if ([...n].length > MAX_CHECKED || HATE_SYMBOLS.test(n) || BLANK_ONLY.test(s) || BLANK_ONLY.test(n)) return false;
|
|
573
|
+
// develop's filter, frozen (LEGACY, at the end of this file): nothing it hides can show
|
|
574
|
+
if (!LEGACY.nameIsSafe(s)) return false;
|
|
575
|
+
if (!checkOne(s)) return false;
|
|
576
|
+
const runs = [...(s.match(ENCLOSED_RUN) || []), ...(s.match(REGIONAL_RUN) || []).filter((r) => r.replace(/[\s._-]/g, "").length >= 12)];
|
|
577
|
+
return runs.every((r) => checkOne(unEnclose(r)));
|
|
578
|
+
}
|
|
579
|
+
/** The strict reading: every look-alike fold, the pt-BR and Spanish lists, the deny lists, develop's "?" reading. */
|
|
580
|
+
function checkOne(s) {
|
|
581
|
+
if (BIDI.test(s)) return false;
|
|
582
|
+
if (NATIVE_DENY.test(s.normalize("NFKD").replace(/\p{M}/gu, "").toLowerCase())) return false;
|
|
583
|
+
if (RAW_DENY.some((re) => re.test(s.toLowerCase()))) return false;
|
|
584
|
+
// dots, underscores, dashes, spaces and invisible characters between the digits don't hide a code ("14.88")
|
|
585
|
+
if (DIGITS_DENY.test(asciiDigits(s).replace(/[\p{Cf}\s._\-]/gu, ""))) return false;
|
|
586
|
+
const fold = (x) => leet(letters(x));
|
|
587
|
+
/** Every I/1/|/! reading, folded; the camelCase-humped copy reuses them when humps change nothing. */
|
|
588
|
+
const folded = (x) => readings(x).map(fold), withHumps = (x, plain) => { const hx = ptHumps(x); return hx === x ? plain : folded(hx); };
|
|
589
|
+
// pt-BR: one copy with digits as separators (puta_123), and each reading with leetspeak folded (p0rr4)
|
|
590
|
+
const h = ptHumps(s);
|
|
591
|
+
if (ptUnsafe([letters(h), ...folded(h)])) return false;
|
|
592
|
+
// ...and with humps only before a Latin capital, so a look-alike capital can't part a word in two (puⲦa, pendeꞲo)
|
|
593
|
+
const hA = String(s).replace(/(\p{Ll})([A-Z])/gu, "$1 $2");
|
|
594
|
+
if (hA !== h && ptUnsafe([letters(hA), ...folded(hA)])) return false;
|
|
595
|
+
// NAME_DENY on the separator-stripped copy, but never from the middle of one word into the next ("Esqueço o nome"),
|
|
596
|
+
// with an allowed whole word set aside (exempt), and camelCase humps as word starts too. A letter that folds to
|
|
597
|
+
// nothing Latin, in a name that has Latin letters, is read both ways: as a "?" (any one letter: "hi?ler", Rip Night's
|
|
598
|
+
// wild reading) and as nothing at all ("nのiのgger", "nㅤiㅤgger": the other families' reading). Either one blocks.
|
|
599
|
+
const kept = exempt(s), keptPlain = folded(kept), keptHumped = withHumps(kept, keptPlain);
|
|
600
|
+
// (the "?" reading here only for words with a Latin letter or of mixed scripts: strictWild. LEGACY reads every word
|
|
601
|
+
// with it, as develop did, so this can't show a name develop hid; it keeps the new folds from making real words of
|
|
602
|
+
// other scripts into near-Latin, Խաչատուր_99 into ...ni?gg)
|
|
603
|
+
const wild = strictWild(kept), wildPlain = wild === kept ? keptPlain : folded(wild), wildHumped = wild === kept ? keptHumped : withHumps(wild, wildPlain);
|
|
604
|
+
for (const [i, l] of keptPlain.entries()) {
|
|
605
|
+
if (ptLegacyUnsafe(NAME_DENY, wildPlain[i] ?? l, wildHumped[i] ?? keptHumped[i], true)) return false;
|
|
606
|
+
if (NON_LATIN.test(l) && ptLegacyUnsafe(NAME_DENY, l, keptHumped[i], false)) return false;
|
|
607
|
+
if ([...l.split(/[^a-z]+/), ...ptWords(l)].some((w) => w && WORD_DENY.some((re) => re.test(w)))) return false;
|
|
608
|
+
}
|
|
609
|
+
// SPACED_DENY, with the innocent words that hold a stem set aside (bípedo, Pakito: ptAside), humps as breaks or not
|
|
610
|
+
const aside = ptAside(s), asidePlain = folded(aside), asideHumped = withHumps(aside, asidePlain);
|
|
611
|
+
for (const x of asidePlain === asideHumped ? asidePlain : [...asidePlain, ...asideHumped]) {
|
|
612
|
+
if (SPACED_DENY.some((re) => re.test(x.replace(/[^a-z]+/g, " ").trim()))) return false;
|
|
613
|
+
if (WHOLE_ACROSS.test(x.replace(/[^a-z]+/g, ""))) return false;
|
|
614
|
+
}
|
|
615
|
+
return true;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/** The first `n` UTF-16 units of `s`, never half an emoji: a cut between a surrogate pair drew "lil gamer �"
|
|
619
|
+
* (2026-10-28). The same length rule as before, so no name is now checked longer than it was. */
|
|
620
|
+
export function cutWhole(s, n) {
|
|
621
|
+
const t = String(s).slice(0, n);
|
|
622
|
+
return /[\uD800-\uDBFF]$/.test(t) ? t.slice(0, -1) : t;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
/** What to draw for a chatter. Unsafe names are not shown at all rather than starred out: a censored slur is still the
|
|
626
|
+
* slur, and still on the stream. */
|
|
627
|
+
export function displayName(name) {
|
|
628
|
+
if ([...String(name || "").normalize("NFKC")].length > MAX_CHECKED) return "a viewer"; // the cap holds before the cut
|
|
629
|
+
const n = cutWhole(String(name || ""), MAX_NAME);
|
|
630
|
+
return nameIsSafe(n) ? n : "a viewer";
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
/** A name's words, the way the pt-BR palavra entries see them (accents, look-alikes and camelCase humps folded; one copy
|
|
634
|
+
* with digits as separators, one per I/1/| reading with leetspeak folded; a run of single letters is one word). Hot
|
|
635
|
+
* Seat's rules.js checks the blocklist stems that Portuguese words hold against these, whole. */
|
|
636
|
+
export function nameWords(name) {
|
|
637
|
+
const h = ptHumps(name);
|
|
638
|
+
return [...LEGACY.nameWords(name), ...[letters(h), ...readings(h).map((x) => leet(letters(x)))].map(ptWords)];
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
/* ---- LEGACY: begin ----
|
|
642
|
+
* prototypes/live-chat/web/name-filter.js as merged on develop at f7f541e4 (sha256 314ac612…), verbatim but for its
|
|
643
|
+
* six `export` keywords, inside a function so its names stay its own. name-filter.test.js holds it to that file.
|
|
644
|
+
* NEVER EDIT: it is what makes the strict check above unable to show a name develop hid. */
|
|
645
|
+
const LEGACY = (() => {
|
|
646
|
+
/**
|
|
647
|
+
* The viewer-name floor for every hosted stream game: one module, so a name one game keeps off the stream is kept off
|
|
648
|
+
* all of them. Pure ESM with no imports: it runs in the browser (boards, panels) and in Node (servers, tests).
|
|
649
|
+
*
|
|
650
|
+
* CANONICAL FILE: prototypes/live-chat/web/name-filter.js. Each game serves its own copy as <game>/name-filter.js
|
|
651
|
+
* (prototypes/stream-games.json lists them); edit this file, then `npm run sync:live-chat`. Each game's own module
|
|
652
|
+
* (chat.js, or names.js) imports its copy and re-exports, so callers don't change.
|
|
653
|
+
*
|
|
654
|
+
* Until 2026-10-20 there were four copies that had drifted apart: the shared chat.js block (Which Way, Chat?, Don't Say
|
|
655
|
+
* It!, Pop Words, Hot Seat, Flock, Cat Café, Emote Defense), Would You Date?'s names.js (the sexual words, whole-word
|
|
656
|
+
* rape/sex/cum/anal, a slur in Cyrillic), Rip Night's names.js (Would You Date?'s plus the RN-2026-10-19 lines: Cherokee
|
|
657
|
+
* look-alikes, allowed whole words, codes split by separators, unknown letters as "?", "the rapist") and Delve's chat.js
|
|
658
|
+
* (Beat the Slime King: bidi overrides, its word-start rules, more look-alikes). This is their union, the strictest
|
|
659
|
+
* reading of each rule, loosened only where a family's tests pass a name (prototypes/live-chat/name-filter.test.js runs
|
|
660
|
+
* every family's lists through every game). Every game reads a name the same way: Delve's reading across the gap
|
|
661
|
+
* between words is gone (the owner, 2026-10-20), so "Toni Grande" passes in every game.
|
|
662
|
+
*
|
|
663
|
+
* A FLOOR, not a moderation system. An adversarial pass on 2026-09-25 put 64 hostile handles through an earlier version
|
|
664
|
+
* of the list and 46 got through. It still won't catch a determined person: a targeted threat like "kill_<streamer>"
|
|
665
|
+
* can't be caught by a stem list without blocking "killerqueen" and "skillz" too. The real answer is the channel's own
|
|
666
|
+
* mods, whose bans reach the boards (Twitch CLEARCHAT). Matching is done on de-obfuscated copies of the name (look-alike
|
|
667
|
+
* letters, accents and leetspeak folded) so the usual evasions don't walk straight through.
|
|
668
|
+
*/
|
|
669
|
+
|
|
670
|
+
const MAX_NAME = 25; // Twitch's own limit
|
|
671
|
+
|
|
672
|
+
/** The extremist stems: part of NAME_DENY, and what makes a word a hate companion of an allowed word (ALLOW_WORDS).
|
|
673
|
+
* (kkk is in the pt-BR block below: kkkk and joao_kkk are Brazilian laughter.) */
|
|
674
|
+
const EXTREMIST = [/(?<!w)hitl/, "heil", "sieghei", "whitepower", "gaschamber", "lynching", "lynchmob", /nazi(?!r)/,
|
|
675
|
+
"auschwitz", "holohoax", "holocaust", "whitepride", /adolf(?!o)/];
|
|
676
|
+
/** Matched on the de-obfuscated copy with separators stripped, but never from the last letter or two of one word into
|
|
677
|
+
* the next (ptLegacyUnsafe, in the floor below). A string matches anywhere; a regex's lookarounds see the whole name. */
|
|
678
|
+
const NAME_DENY = [
|
|
679
|
+
// Impersonating the platform, however it's separated ("TikTok_Admin", "tik tok support", "Twitch_Official").
|
|
680
|
+
// (TikTok_Moda and youtube_moda, fashion accounts, pass: the es draft. TikTok_Mod and tiktokmoderator don't.)
|
|
681
|
+
"tiktokadmin", "tiktoksupport", "tiktokstaff", "tiktokofficial", /tiktokmod(?!as?$)/, "tiktokteam", "tiktokpartner",
|
|
682
|
+
"twitchstaff", "twitchsupport", "twitchadmin", /twitchmod(?!as?$)/, "twitchofficial", "twitchteam", "twitchpartner",
|
|
683
|
+
"youtubestaff", "youtubesupport", "youtubeofficial", "youtubeadmin", /youtubemod(?!as?$)/, "youtubeteam", "youtubepartner",
|
|
684
|
+
// Slurs. Pakistão, retardar and retardatário pass (the pt-BR draft); hospício, auspicioso and perspicaz too;
|
|
685
|
+
// kikeriki (a rooster's crow), Van Dyke and vandyke pass as whole words only (ALLOW_WORDS).
|
|
686
|
+
"nigg", "nigr", "faggot", "fagg", "tranny", "kike", /spic(?![aeiy])/, "chink", "wetback", /(?<!rac|ty|co)coon/,
|
|
687
|
+
"beaner", "gook", "raghead", "towelhead", /paki(?!sta[no])/, "dyke", "shemale", /retard(?!a[rt])/, "spastic",
|
|
688
|
+
"mongoloid",
|
|
689
|
+
// Extremist (EXTREMIST, below).
|
|
690
|
+
...EXTREMIST,
|
|
691
|
+
// Threats and self-harm. Deliberately narrow: "kill" alone is far too common in real handles (killerqueen, skillz).
|
|
692
|
+
"kys", "killurself", "killyourself", "killyrself", "swatting", /(?<!the|te)rapist/, "iwillkill", // terapista, fisioterapista
|
|
693
|
+
"slityourwrist", "hangyourself", "neckyourself",
|
|
694
|
+
// Sexual (Would You Date?'s pre-live gate: r4pe_u, onlyfans_link, pornhub_com).
|
|
695
|
+
"porn", "onlyfans", "fansly", "hentai", "camgirl", "camwhore", "sexy", "milf", "dildo", "boobs",
|
|
696
|
+
"pussy", "slut", "whore", /(?<!t)horny/, "blowjob", "handjob", "cumshot",
|
|
697
|
+
// Child-safety. These have no innocent reading in a handle.
|
|
698
|
+
// torpedo, pedometer, pedômetro (Slime King's rule); qué pedo, and Loli Contreras or Concepción (the es draft)
|
|
699
|
+
/(?<!tor|que)pedo(?!met)/, "pedofil", "pedophil", "groomer", "jailbait", /lolicon(?!treras|cepcion|suegra|tento|tador|stantin|de$)/, "childp",
|
|
700
|
+
// Scams: the ones that turn an overlay into a phishing surface.
|
|
701
|
+
"freebits", "freesubs", "freenitro", "giveawaybot", "clickhere",
|
|
702
|
+
];
|
|
703
|
+
/** Whole words only (on the separator-split copy, and with a spelled-out run of single letters as one word: "r.a.p.e"),
|
|
704
|
+
* where a substring would hit ordinary words: "rape" starts a word in r4pe_u but sits inside grape, drape and scrape
|
|
705
|
+
* (Would You Date?). A word that starts "rape" blocks (rapelover, RapeLord) unless it is one of the innocent whole
|
|
706
|
+
* words that do (the owner, 2026-10-20): Spanish rapero/rapera (a rapper), English rapeseed, Portuguese rapei, rapem,
|
|
707
|
+
* rapemos (rapar). Rapel (rappelling, in Which Way, Chat?'s pt-BR deck, which dial/check-deck.test.js holds to this
|
|
708
|
+
* filter) passes only as the whole name: ALLOW_ALONE. */
|
|
709
|
+
const WORD_DENY = [/^rape(?!(?:i|is|m|mos|n|ros?|ras?|seeds?)$)/, /^raping$/, /^sex$/, /^cum$/, /^anal$/];
|
|
710
|
+
/** English entries read the pt-BR palavra way (a whole word, plural -s, a run of a letter, spelled out): nude, nudes,
|
|
711
|
+
* n.u.d.e, nud3, not denude, menudear, estornude or nudez (the owner, 2026-10-20). */
|
|
712
|
+
const EN_PALAVRA = ["nude"];
|
|
713
|
+
/** On the spaced copy (separators, and camelCase humps in one reading, as single spaces), where a joined copy can't
|
|
714
|
+
* tell: "the_rapist" and "TheRapist" read "therapist" joined (Rip Night, RN-2026-10-19). With Slime King's word-start
|
|
715
|
+
* rules (the 2026-10-15 pre-live review), which name the innocent continuations they let through. */
|
|
716
|
+
const SPACED_DENY = [/\bthe rapist/,
|
|
717
|
+
/(?<!the|te)rapist/, /(?<!tor|que ?)pedo(?!met)/, /\bspic(?![yeau])/, /\bcoon(?!an|ey|ie)/, /\bnazi(?![ar])/,
|
|
718
|
+
/(?<!van )\bdyke/, /\bheil(?:\b|[hs])/, /\bpaki(?!ze|sta[no]|sh)/, /\bkys\b/, /\bgook/, /\bkike(?!riki)/, /\bchink(?!apin)/];
|
|
719
|
+
/** Ordinary names a substring rule hits (Slime King's review: Nazia, Heilmann, Pakize, Coonan; and Sheila; Would You
|
|
720
|
+
* Date?'s kikeriki and Van Dyke). Only a WHOLE word is let through: no letter glued on either side ("naziarmy",
|
|
721
|
+
* "NaziaArmy", "kkkxNazia" block), but separators and digits are word breaks ("nazia2001" passes), on the NFKC copy
|
|
722
|
+
* (squared or full-width letters read as plain). And only beside ordinary words: the exemption is off, and the name is matched like any other, when the rest of it holds a Nazi number
|
|
723
|
+
* (HATE_NUMBER, in digits of any script, split or not: "Heilmann_88", "nazia_8_8", "nazia_๘๘"), an extremist stem
|
|
724
|
+
* (EXTREMIST: "Sheila_Heil"), a Klan or Nazi word (HATE_COMPANION, leetspeak and look-alikes folded: "Sieg_Heilmann",
|
|
725
|
+
* "Nazia_$$", "Coonan_k|an"), or a second allowed word. "Nazia_Khan", "sheila_99", "Sheila White" and "Coonan Boys"
|
|
726
|
+
* pass. */
|
|
727
|
+
const ALLOW_WORDS = ["nazia", "heilmann", "sheila", "pakize", "coonan", "kikeriki", "vandyke", "van[\\s._-]+dyke"];
|
|
728
|
+
const ALLOWED = new RegExp(`(?<!\\p{L})(?:${ALLOW_WORDS.join("|")})(?!\\p{L})`, "giu");
|
|
729
|
+
/** Klan and Nazi words that make an allowed word read as what it holds: specific terms only, never ordinary words
|
|
730
|
+
* (white, power, grand, boys, the). "army" and "party" stay: "Nazia Army", "Nazia Party" read as nazi army, Nazi Party. Matched on the folded and leet-read
|
|
731
|
+
* rest of the name, a spelled-out run of single letters as one word ("s.i.e.g"). */
|
|
732
|
+
const HATE_COMPANION = /^(?:sieg|siegs|heils?|hh|sss?|ns|nsdap|kkk+|klans?|klux|kluxer|reichs?|fuhrers?|fuehrers?|wehrmacht|waffen|swastikas?|hakenkreuz|gestapo|totenkopf|aryans?|army|armies|armee|heer|party|xiv|lxxxviii)$/;
|
|
733
|
+
/** Nazi and hate numbers (88 HH, 14 words, 18 AH, 28 BH, 83 HC, 311 KKK, and the 1488 family). */
|
|
734
|
+
const HATE_NUMBER = /^(?:88|14|18|28|83|311|148|1418|8888|1488|8814)$|1488|8814/;
|
|
735
|
+
/** Passes only as the whole name, nothing beside it: "Rapel" (a deck word), not "rapel_her" or "rapel lover". */
|
|
736
|
+
const ALLOW_ALONE = /^rapels?$/;
|
|
737
|
+
/** The name with its allowed words set aside (" " for a whole-name ALLOW_ALONE word), or the name itself when the
|
|
738
|
+
* rest of it says otherwise. */
|
|
739
|
+
function exempt(s) {
|
|
740
|
+
const words = ptWords(letters(ptHumps(s)));
|
|
741
|
+
if (words.length === 1 && ALLOW_ALONE.test(words[0]) && !/[\p{N}\p{L}]/u.test(s.replace(/[a-z]/gi, ""))) return " ";
|
|
742
|
+
const base = romanDigits(s).normalize("NFKC"), kept = base.replace(ALLOWED, " ");
|
|
743
|
+
if (kept === base) return s;
|
|
744
|
+
if ((base.match(ALLOWED) || []).length > 1) return s; // one allowed word ("nazia nazia" isn't a name)
|
|
745
|
+
// numbers in digits of any script (Roman numerals and keycaps too), joined across separators ("8_8", "1.4.8.8", "ⅧⅧ")
|
|
746
|
+
if ((asciiDigits(kept).replace(/[\p{Cf}\p{M}\s._\-]+/gu, "").match(/[0-9]+/g) || []).some((n) => HATE_NUMBER.test(n))) return s;
|
|
747
|
+
const hate = (w) => HATE_COMPANION.test(w) || EXTREMIST.some((r) => (typeof r === "string" ? w.includes(r) : r.test(w)));
|
|
748
|
+
// SS bolts and 8-balls stand for SS and 88 beside a name that holds nazi or heil
|
|
749
|
+
if (/\u26A1\uFE0F?[\s._-]*\u26A1|\u{1F3B1}[\s._-]*\u{1F3B1}/u.test(kept)) return s;
|
|
750
|
+
// enclosed letters and regional indicators are words here too, each run its own ("nazia_🅢🅢", "nazia 🇭🇭"), and a run
|
|
751
|
+
// of any length that is unsafe on its own ("Nazia 🇰🇮🇰🇪") takes the exemption away
|
|
752
|
+
// (one real flag is a flag: "🇸🇸 Nazia" is South Sudan; "nazia 🇭🇭" isn't a flag)
|
|
753
|
+
const flagless = kept.replace(REGIONAL_RUN, (r) => { const u = unEnclose(r).replace(/[^a-z]/g, ""); return u.length === 2 && FLAGS.has(u) ? " " : r; });
|
|
754
|
+
const runs = [...(flagless.match(ENCLOSED_RUN) || []), ...(flagless.match(REGIONAL_RUN) || [])].map(unEnclose);
|
|
755
|
+
if (runs.some((r) => !checkOne(r))) return s;
|
|
756
|
+
const h = ptHumps(flagless.replace(ENCLOSED_RUN, (r) => ` ${unEnclose(r)} `).replace(REGIONAL_RUN, (r) => ` ${unEnclose(r)} `)
|
|
757
|
+
.replace(/\|-\|/g, "h").replace(/\u20AC/g, "e").replace(/\u00A5/g, "y").replace(/[\u00DF\u1E9E]/g, "ss").replace(/\u0282/g, "s") // reic|-|, r€ich, Arm¥, ß
|
|
758
|
+
.replace(/(^|[^\p{L}\p{N}|!])[|!]+(?=[\p{L}\p{N}])/gu, "$1 ") // "Nazia|k|an": the first | parts
|
|
759
|
+
.replace(/(?<=[\p{L}\p{N}])[|!]+(?![\p{L}\p{N}])/gu, " ")); // "k|an|Nazia": the last | too
|
|
760
|
+
// folded as the main check folds: look-alikes, leetspeak ($$, @rmy), and | ! read as letters or as separators
|
|
761
|
+
return [letters(h), leet(letters(h)), ...readings(h).map((x) => leet(letters(x)))].some((c) => ptWords(c).some(hate)) ? s : kept;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
/** Numeric codes, checked on the RAW handle: the leet fold that catches letter evasions destroys digits. A bare "88" is
|
|
765
|
+
* far too common in real handles (birth years) to block on its own. Also on the digits-only copy (dots, underscores,
|
|
766
|
+
* dashes, spaces and invisible characters dropped: "14.88", "14_88"). */
|
|
767
|
+
const RAW_DENY = [/1488/, /\b14\s*88\b/, /\b88\s*14\b/,
|
|
768
|
+
// A few slurs written in their own script, which the Latin fold can't reach (the PR #1831 review: Russian "pidor").
|
|
769
|
+
/пид[оа]р/, /педик/];
|
|
770
|
+
const DIGITS_DENY = /1488|8814/;
|
|
771
|
+
/** Bidi overrides and isolates have no place in a name: they exist to make a name read as something else
|
|
772
|
+
* ("\u202Ereltih" draws as hitler). A game that cleans a name for drawing strips them first (cleanName). */
|
|
773
|
+
const BIDI = /[\u202A-\u202E\u2066-\u2069]/;
|
|
774
|
+
|
|
775
|
+
/** Look-alike letters folded to Latin before the deny check: Cyrillic, Greek (capitals too, mapped before lowercasing,
|
|
776
|
+
* or Η would become η and read as "n"), IPA, small capitals, dotless and barred letters, and the Cherokee capitals that
|
|
777
|
+
* pass for Latin ("hiᏆler", a "Ꮐengduck" impostor). NFKD turns full-width (hitler), maths letters (𝐡𝐢𝐭𝐥𝐞𝐫), ſ and
|
|
778
|
+
* Roman numerals into plain ones and splits accents off, so "hítler" can't lose its í. */
|
|
779
|
+
const CONFUSABLE = {
|
|
780
|
+
// Cyrillic
|
|
781
|
+
"А": "a", "В": "b", "Е": "e", "К": "k", "М": "m", "Н": "h", "О": "o", "Р": "p", "С": "c", "Т": "t", "У": "y", "Х": "x", "Ѕ": "s", "І": "i", "Ј": "j", "Ү": "y",
|
|
782
|
+
"а": "a", "в": "b", "е": "e", "к": "k", "м": "m", "н": "h", "о": "o", "р": "p", "с": "c", "т": "t", "у": "y", "х": "x", "ѕ": "s", "і": "i", "ї": "i", "ј": "j", "ԁ": "d", "ӏ": "l", "ү": "y",
|
|
783
|
+
// Greek
|
|
784
|
+
"Α": "a", "Β": "b", "Ε": "e", "Ζ": "z", "Η": "h", "Ι": "i", "Κ": "k", "Μ": "m", "Ν": "n", "Ο": "o", "Ρ": "p", "Τ": "t", "Υ": "y", "Χ": "x",
|
|
785
|
+
"α": "a", "β": "b", "ε": "e", "ζ": "z", "η": "n", "ι": "i", "κ": "k", "ν": "v", "ο": "o", "ρ": "p", "τ": "t", "υ": "u", "χ": "x", "γ": "y", "ω": "w", "μ": "u",
|
|
786
|
+
// Latin look-alikes NFKD leaves alone, and small capitals
|
|
787
|
+
"ı": "i", "ɩ": "i", "ɨ": "i", "ɑ": "a", "ɒ": "a", "ɡ": "g", "ǥ": "g", "ɢ": "g", "ł": "l", "ø": "o", "đ": "d", "ħ": "h", "ŧ": "t", "ƀ": "b", "ɍ": "r", "ʉ": "u", "ɇ": "e",
|
|
788
|
+
"ᴀ": "a", "ʙ": "b", "ᴄ": "c", "ᴅ": "d", "ᴇ": "e", "ʜ": "h", "ɪ": "i", "ᴊ": "j", "ᴋ": "k", "ʟ": "l", "ᴍ": "m", "ɴ": "n", "ᴏ": "o", "ᴘ": "p",
|
|
789
|
+
"ʀ": "r", "ꜱ": "s", "ᴛ": "t", "ᴜ": "u", "ᴠ": "v", "ᴡ": "w", "ʏ": "y", "ᴢ": "z",
|
|
790
|
+
// Cherokee capitals
|
|
791
|
+
"Ꭺ": "a", "Ᏼ": "b", "Ꮯ": "c", "Ꭼ": "e", "Ꮐ": "g", "Ꮋ": "h", "Ꮖ": "t", "Ꭻ": "j", "Ꮶ": "k", "Ꮮ": "l", "Ꮇ": "m", "Ꮎ": "o", "Ꮲ": "p", "Ꭱ": "r", "Ꮪ": "s", "Ꭲ": "t", "Ꮩ": "v", "Ꮃ": "w", "Ꮓ": "z",
|
|
792
|
+
};
|
|
793
|
+
// A capital I, 1, | or ! can stand for i or for l ("hitIer", "HITIER", "hit1er"): every reading is checked, up
|
|
794
|
+
// to 16 of them (beyond 4 such characters, all-i and all-l).
|
|
795
|
+
function readings(name) {
|
|
796
|
+
const s = String(name ?? "").normalize("NFKC"), k = (s.match(/[I1|!]/g) || []).length, n = k <= 4 ? 1 << k : 2;
|
|
797
|
+
return Array.from({ length: n }, (_, c) => { let j = 0; return s.replace(/[I1|!]/g, () => ((k <= 4 ? (c >> j++) & 1 : c) ? "l" : "i")); });
|
|
798
|
+
}
|
|
799
|
+
/** Enclosed Latin capitals that NFKD leaves alone or wraps (parenthesized 🄐, circled 🄠, squared 🄰, negative circled 🅐,
|
|
800
|
+
* negative squared 🅰) and the regional indicator letters (🇳🇮🇬…, which draw as flags in pairs). The name is read with
|
|
801
|
+
* them as separators, as before ("n🇺i🇺g🇺g🇺e🇺r"); then each run of them (separators between allowed) is read as a-z ON
|
|
802
|
+
* ITS OWN, never joined to the letters or words beside it, so "🇰🇾 Sam" and "🇺🇸Nazia" are a flag and a name. A run of
|
|
803
|
+
* regional indicators counts only from six letters (three flags): two flags side by side (🇵🇪🇩🇴, 🇳🇮🇬🇷, 🇰🇪🇰🇮) are
|
|
804
|
+
* ordinary dual-nationality decoration and spell a stem by accident far more often than on purpose. */
|
|
805
|
+
const ENCLOSED_RUN = /[\u{1F110}-\u{1F189}](?:[\s._-]*[\u{1F110}-\u{1F189}])*/gu;
|
|
806
|
+
const REGIONAL_RUN = /[\u{1F1E6}-\u{1F1FF}](?:[\s._-]*[\u{1F1E6}-\u{1F1FF}])*/gu;
|
|
807
|
+
/** The ISO 3166-1 codes, so one real flag beside an allowed word reads as a flag. */
|
|
808
|
+
const FLAGS = new Set(("ad ae af ag ai al am ao aq ar as at au aw ax az ba bb bd be bf bg bh bi bj bl bm bn bo bq br bs bt bv bw by " +
|
|
809
|
+
"bz ca cc cd cf cg ch ci ck cl cm cn co cr cu cv cw cx cy cz de dj dk dm do dz ec ee eg eh er es et fi fj fk " +
|
|
810
|
+
"fm fo fr ga gb gd ge gf gg gh gi gl gm gn gp gq gr gs gt gu gw gy hk hm hn hr ht hu id ie il im in io iq ir " +
|
|
811
|
+
"is it je jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc li lk lr ls lt lu lv ly ma mc md me mf mg mh mk " +
|
|
812
|
+
"ml mm mn mo mp mq mr ms mt mu mv mw mx my mz na nc ne nf ng ni nl no np nr nu nz om pa pe pf pg ph pk pl pm " +
|
|
813
|
+
"pn pr ps pt pw py qa re ro rs ru rw sa sb sc sd se sg sh si sj sk sl sm sn so sr ss st sv sx sy sz tc td tf " +
|
|
814
|
+
"tg th tj tk tl tm tn to tr tt tv tw tz ua ug um us uy uz va vc ve vg vi vn vu wf ws ye yt za zm zw").split(" "));
|
|
815
|
+
const ENCLOSED = /[\u{1F110}-\u{1F189}\u{1F1E6}-\u{1F1FF}]/gu;
|
|
816
|
+
const unEnclose = (s) => s.replace(ENCLOSED, (ch) => {
|
|
817
|
+
const cp = ch.codePointAt(0), base = cp >= 0x1F1E6 ? 0x1F1E6 : cp >= 0x1F170 ? 0x1F170 : cp >= 0x1F150 ? 0x1F150 : cp >= 0x1F130 ? 0x1F130 : 0x1F110;
|
|
818
|
+
return cp - base < 26 ? String.fromCharCode(97 + cp - base) : ch;
|
|
819
|
+
});
|
|
820
|
+
/** Digits of any script as 0-9 (NFKC handles full-width, maths, circled and superscript ones; this takes the rest:
|
|
821
|
+
* Thai ๘, Devanagari ८, Arabic-Indic ٨). */
|
|
822
|
+
/** Roman numeral characters as digits, one each (ⅧⅧ is 88), before NFKC spells them out as letters. */
|
|
823
|
+
const romanDigits = (s) => s.replace(/[\u2160-\u216B\u2170-\u217B]/g, (ch) => String((ch.charCodeAt(0) & 0xF) + 1));
|
|
824
|
+
const asciiDigits = (s) => romanDigits(s).normalize("NFKC").replace(/(?![0-9])\p{Nd}/gu, (ch) => {
|
|
825
|
+
let cp = ch.codePointAt(0), k = 0;
|
|
826
|
+
while (k < 9 && /\p{Nd}/u.test(String.fromCodePoint(cp - 1))) { cp--; k++; }
|
|
827
|
+
return String(k);
|
|
828
|
+
});
|
|
829
|
+
/** Accents and format characters off, look-alikes folded, lowercased; separators and digits still in place. */
|
|
830
|
+
const CONFUSABLE_RE = new RegExp(`[${Object.keys(CONFUSABLE).join("")}]`, "gu"), LETTERS = new Map();
|
|
831
|
+
const letters = (name) => {
|
|
832
|
+
const s = String(name ?? "");
|
|
833
|
+
let out = LETTERS.get(s);
|
|
834
|
+
if (out === undefined) {
|
|
835
|
+
out = s.normalize("NFKD").replace(/[\p{M}\p{Cf}]/gu, "").replace(CONFUSABLE_RE, (ch) => CONFUSABLE[ch])
|
|
836
|
+
.toLowerCase().replace(CONFUSABLE_RE, (ch) => CONFUSABLE[ch]);
|
|
837
|
+
if (LETTERS.size >= 20000) LETTERS.clear(); // one name's readings and copies ask for the same folds many times
|
|
838
|
+
LETTERS.set(s, out);
|
|
839
|
+
}
|
|
840
|
+
return out;
|
|
841
|
+
};
|
|
842
|
+
const leet = (s) => s.replace(/3/g, "e").replace(/0/g, "o").replace(/[69]/g, "g")
|
|
843
|
+
.replace(/5|\$/g, "s").replace(/4|@/g, "a").replace(/7/g, "t");
|
|
844
|
+
/** A name folded for comparing identities (a viewer named like the streamer): accents, width, case and look-alike
|
|
845
|
+
* letters folded; separators and digits kept. The games' impostor checks build on it. */
|
|
846
|
+
const foldLetters = letters;
|
|
847
|
+
|
|
848
|
+
/* ---- pt-BR name floor: begin ----
|
|
849
|
+
* The entries are prototypes/live-chat/review/pt-BR-name-filter-draft.md, which the Brazilian reviewer greenlit as
|
|
850
|
+
* drafted (2026-10-19), and the Spanish ones (ES_*) are review/es-name-filter-draft.md, shipped without a native
|
|
851
|
+
* reviewer on the owner's word (2026-10-19: "let the players tell us what to adjust"). ptUnsafe() is given
|
|
852
|
+
* de-obfuscated copies of the name: lowercase, accents and look-alike letters folded (ñ reads as n, ü as u), one copy
|
|
853
|
+
* with leetspeak folded and one with digits left as separators. Anything that isn't a-z is a separator. A letter in
|
|
854
|
+
* an entry matches a run of it ("puuuta", "viiiado"), and a run of single letters reads as one word ("p.u.t.a",
|
|
855
|
+
* "f d p"). */
|
|
856
|
+
const PT_LOOSE = (w) => w.replace(/[a-z]/g, "$&+");
|
|
857
|
+
/** trecho: inside a word, or from the start of a word across separators ("v.i.a.d.o", "filho_da_puta"). Never from
|
|
858
|
+
* the middle of one word into the next, so two names can't spell one ("Lívia do Carmo" isn't viado). */
|
|
859
|
+
const PT_TRECHO = [
|
|
860
|
+
// viado, not enviado, aliviado, desviado, transviado, abreviado, aviado, extraviado, ataviado, esgrouviado or
|
|
861
|
+
// aviador; nor Spanish obviado, antuviado, engaviado, nerviado, or silviadominguez as one lowercase login (es §3)
|
|
862
|
+
/(?<!li|xi|es|ns|en|re|lu|nu|ta|ra|sa|ea|ob|tu|ga|er|il|ou|^a)v+i+a+d+o+(?!r)/, "boiola", "baitola", "sapatao",
|
|
863
|
+
"fanchona", "traveco", "crioulo", "aleijado", "debilmental",
|
|
864
|
+
// boceta, bocetas, bocetão, not Spanish bocetar, bocetado, bocetando, bocetaba, bocetamos, bocetaste (to sketch)
|
|
865
|
+
"vagabunda", "buceta", /b+o+c+e+t+a+(?![rdbnm]|s[et])/, "xoxota", "xereca", "piroca", "caralho", "punheta", "siririca",
|
|
866
|
+
"boquete",
|
|
867
|
+
/f+o+de+r+(?!aro)/, "fodid", "fodase", "novinha", "ninfeta", // foder, not cannon_fodder or Foderaro
|
|
868
|
+
/a+r+r+o+m+b+a+d+o+(?!r)/, "cuzao", "filhodaputa", "vaisematar", "voutematar", // arrombado, not arrombador (a burglar)
|
|
869
|
+
/a+n+a+u+e+(?![dnhm])/, // anauê, not Ana Ueda, Ana Ueno, Ana Uehara
|
|
870
|
+
"tiktokoficial", "twitchoficial", "youtubeoficial", "suportetiktok", "suportetwitch", "suporteyoutube",
|
|
871
|
+
"equipetiktok", "equipetwitch", "equipeyoutube", "admtiktok", "admtwitch", "pixgratis", "ganhepix", "sorteiobot",
|
|
872
|
+
"cliqueaqui", "linknabio", "bitsgratis", "subsgratis",
|
|
873
|
+
].map((r) => (typeof r === "string" ? PT_LOOSE(r) : r.source));
|
|
874
|
+
/** trecho, but only from the start of a word: "se mata" and "te mato" sit inside José Mata and Dante Matos. */
|
|
875
|
+
const PT_TRECHO_START = ["semata", "temato", "seenforca"].map(PT_LOOSE);
|
|
876
|
+
/** palavra: a whole word between separators (_ . - spaces digits), plural -s too: puta_123 and putas, not disputa. */
|
|
877
|
+
const PT_PALAVRA = ["bicha", "mulherzinha", "macaco", "macaca", "ticao", "mongol", "puta", "putinha", "rapariga",
|
|
878
|
+
"krl", "crl", "gostosa", "safada", "fdp", "vsf", "vtnc", "tnc", "pqp", "corno", "suicida", "integralista"];
|
|
879
|
+
/** palavra without the plural: porra and pica, not Porras (a Spanish surname) or picas (spades, in Spanish cards). */
|
|
880
|
+
const PT_PALAVRA_ONE = ["porra", "pica"];
|
|
881
|
+
/** The Spanish entries (es-name-filter-draft.md §1, §5), as drafted except: caraverga and careverga not before an r
|
|
882
|
+
* (Cara Vergara), and the -es plurals of the palavra words that end in a consonant (cabrones, culones, mamones). */
|
|
883
|
+
const ES_TRECHO = [
|
|
884
|
+
"machorra", "marimacho", "sidoso", "sidosa", /s+u+d+a+c+a+(?!o)/, "mongolic", "mogolic", "subnormal",
|
|
885
|
+
"hijodeputa", "hijadeputa", "hijoputa", "hijaputa", "hijueputa", "jueputa", "granputa", "putamadre",
|
|
886
|
+
"chingar", "chingad", "chingatumadre", "vergud", "chupaverga", "chupapija", "chupapolla", "poronga", "singao",
|
|
887
|
+
"mamabicho", /(?<!ja)m+i+e+r+d+a+/, "joder", /(?<![ais])f+o+l+l+a+r+/, "mamaguevo", "mamahuevo", "mamaguebo",
|
|
888
|
+
"pajillero", "culiao", "culiad", "malparid", "malnacid", /c+a+r+[ae]+v+e+r+g+a+(?!r)/, "carechimba", "caremonda", "gilipollas",
|
|
889
|
+
"suicidate", "ahorcate", "tevoyamatar", "voyamatarte", "cortatelasvenas",
|
|
890
|
+
"pederast", "menorcit", "vendocp", "cpgratis", "poderblanco", "orgulloblanco",
|
|
891
|
+
/r+a+z+a+a+r+i+a+(?!s)/, // raza aria, not Raza Arias
|
|
892
|
+
// conchatumadre, conchetumare, conchesumadre, concha de tu madre; coño de tu madre, coñoetumadre
|
|
893
|
+
/c+o+n+c+h+[aeu]+(?:d+e+)?[st]+u+m+a+(?:d+)?r+e+/, /c+o+n+o+(?:d+)?e+t+u+m+a+(?:d+)?r+e+/,
|
|
894
|
+
...["soporte", "equipo", "oficial", "moderador", "admin", "administrador", "ayuda"]
|
|
895
|
+
.flatMap((w) => ["tiktok", "twitch", "youtube"].map((p) => w + p)),
|
|
896
|
+
"tiktoksoporte", "twitchsoporte", "youtubesoporte", "tiktokayuda", "twitchayuda", "youtubeayuda", "sorteobot",
|
|
897
|
+
"clicaqui", "clickaqui", "hazclic", "linkenbio", "linkenlabio", "enlaceenbio", "monedasgratis", "seguidoresgratis",
|
|
898
|
+
"nitrogratis",
|
|
899
|
+
].map((r) => (typeof r === "string" ? PT_LOOSE(r) : r.source));
|
|
900
|
+
// (sudaca not before o: pt sudação, transudação; mierda not after ja: jamerdar; follar not after a, i or s:
|
|
901
|
+
// afollar, emperifollar, cachifollar, desfollar)
|
|
902
|
+
/** te mataré, from the start of a word only (temática passes; the unlikely name Tema Tarea doesn't). */
|
|
903
|
+
const ES_TRECHO_START = ["tematare"].map(PT_LOOSE);
|
|
904
|
+
/** palavra. Never trecho: verga (Vergara), culo (artículo, cálculo), pija (pijama), polla (pollo), teta (tetera),
|
|
905
|
+
* pene (Penélope), puto (cómputo, diputado), maricon (Mari Contreras), jodido (Jodi Díaz), negrata (Negra Tamara), matate (Mata Teresa).
|
|
906
|
+
* puto, pene and mamon don't take a doubled consonant (putto, penne, Mammon). */
|
|
907
|
+
const ES_PALAVRA = ["maricon", "maricones", "mariconazo", "marica", "marika", "marico", "joto", /p+u+to+/, "trolo",
|
|
908
|
+
"maraco", "fleto", "pirobo", "playo", "tortillera", "bollera", "travelo", "negrata", "veneco", "veneca", "moraco", "mayate",
|
|
909
|
+
"retrasado", "retrasada", "tarado", "tarada", "putita", "putona", "hdp", "ptm", "ctm", "csm", "conchudo", "conchuda",
|
|
910
|
+
"chinga", "verga", "chupala", "chupamela", "pija", "pijudo", "pinga", "polla", "singar", /p+e+ne+/, "teta", "tetona",
|
|
911
|
+
"culo", "culon", "culones", "culona", "ojete", "jodido", "jodida", "jodete", "mamada", /m+a+mo+n+/, "mamones", "mmgv",
|
|
912
|
+
"pajero", "panocha", "chucha", "zorra", "perra", "guarra", "golfa", "prostituta", "violador", "violadora", "puneta",
|
|
913
|
+
"ql", "cagon", "cagones", "cagona", "gonorrea", "pendejo", "pendeja", "culero", "culera", "cabron", "cabrones",
|
|
914
|
+
"cabrona", "boludo", "boluda", "pelotudo", "pelotuda", "cojudo", "aweonao", "ahueonao", "sorete", "cornudo", "cornuda",
|
|
915
|
+
"matate", "muerete", "falangista"];
|
|
916
|
+
const PT_INSIDE_RE = new RegExp([...PT_TRECHO, ...ES_TRECHO].join("|"));
|
|
917
|
+
const PT_FROM_START_RE = new RegExp(`^(?:${[...PT_TRECHO, ...PT_TRECHO_START, ...ES_TRECHO, ...ES_TRECHO_START].join("|")})`);
|
|
918
|
+
const PT_PALAVRA_RE = new RegExp(`^(?:${[...PT_PALAVRA, ...ES_PALAVRA, ...EN_PALAVRA].map((r) => (typeof r === "string" ? PT_LOOSE(r) : r.source))
|
|
919
|
+
.join("|")})s*$|^(?:${PT_PALAVRA_ONE.map(PT_LOOSE).join("|")})$`);
|
|
920
|
+
/** kkk is Brazilian laughter (kkkk, joao_kkk). It is the Klan as the whole name (kkk, k.k.k, KKK_88) or beside a
|
|
921
|
+
* Klan word (kkk_member, the_kkk, kkkklan). */
|
|
922
|
+
const PT_KLAN_AFTER = /^(?:klan|klux|members?|wizards?|knights?|rally|army|nation|hood)$/, PT_KLAN_BEFORE = /^(?:the|grand|white|imperial)$/;
|
|
923
|
+
const PT_KLAN_JOINED = /(?<!k)kkk(?:klan|klux|member|wizard|knight|rally|army|nation|hood)|(?:the|grand|white|imperial)kkk(?!k)/;
|
|
924
|
+
/** camelCase humps are word breaks too, so a Twitch display name reads as its parts: "SilviaDourado" isn't viado,
|
|
925
|
+
* "FilhoDaPuta" still is. Applied to the name before it is folded into copies. */
|
|
926
|
+
const ptHumps = (name) => String(name ?? "").replace(/(\p{Ll})(\p{Lu})/gu, "$1 $2");
|
|
927
|
+
function ptWords(copy) {
|
|
928
|
+
const out = [];
|
|
929
|
+
let single = false;
|
|
930
|
+
for (const w of String(copy).replace(/[^a-z]+/g, " ").trim().split(" ")) {
|
|
931
|
+
if (!w) continue;
|
|
932
|
+
if (w.length === 1 && single) out[out.length - 1] += w; // a run of single letters is one spelled-out word
|
|
933
|
+
else out.push(w);
|
|
934
|
+
single = w.length === 1;
|
|
935
|
+
}
|
|
936
|
+
return out;
|
|
937
|
+
}
|
|
938
|
+
function ptUnsafe(copies) {
|
|
939
|
+
for (const copy of copies) {
|
|
940
|
+
const words = ptWords(copy), joined = words.join("");
|
|
941
|
+
if (!joined) continue;
|
|
942
|
+
if (words.some((w) => PT_INSIDE_RE.test(w))) return true;
|
|
943
|
+
// from each word's start, through the words after it (a lookbehind sees nothing of the word before)
|
|
944
|
+
for (let i = 0, at = 0; i < words.length; at += words[i++].length) if (PT_FROM_START_RE.test(joined.slice(at))) return true;
|
|
945
|
+
if (words.some((w, i) => PT_PALAVRA_RE.test(w) && !(/^p+i+c+a+$/.test(w) && /^p+a+u+$/.test(words[i + 1] || "")))) return true; // pica-pau, the woodpecker
|
|
946
|
+
if (joined === "kkk" || PT_KLAN_JOINED.test(joined)) return true;
|
|
947
|
+
if (words.some((w, i) => w === "kkk" && (PT_KLAN_AFTER.test(words[i + 1] || "") || PT_KLAN_BEFORE.test(words[i - 1] || "")))) return true;
|
|
948
|
+
}
|
|
949
|
+
return false;
|
|
950
|
+
}
|
|
951
|
+
/** The English-era rules (each family's NAME_DENY) ran on the name with every separator stripped, so one could start
|
|
952
|
+
* inside a word and run on into the next: "Esqueço o nome" read as esque-coon-ome, "Diego Okada" as die-gook-ada.
|
|
953
|
+
* A hit now counts where a trecho's does, inside one word or from the start of a word across separators
|
|
954
|
+
* ("coonhunter", "c.o.o.n", "nig.ger"), and where three or more of its letters sit in the word it starts in
|
|
955
|
+
* ("thenig ger"): every collision the word lists turned up was the last one or two letters of a word (2026-10-19).
|
|
956
|
+
* Lookarounds still see the whole joined name, as before, so nothing new is blocked. Digits and non-Latin letters stay inside their word (they used to vanish), and `humped` is the same copy
|
|
957
|
+
* with camelCase humps as breaks, whose word starts count too ("MyTikTokAdmin"). `wild`: a non-Latin letter in a
|
|
958
|
+
* Latin name is a "?", any one letter, once per hit (Rip Night's old looseIncludes); regex rules see the name without
|
|
959
|
+
* it. SPACED_DENY is matched another way, so it sets ES_LEGACY_OK's words aside (ptAside). */
|
|
960
|
+
const PT_STICKY = new Map();
|
|
961
|
+
/** -ar verb endings, Spanish and Portuguese, and their participles (ES_ADO: not for retard, so retardado stays blocked). */
|
|
962
|
+
const ES_AR = "(?:a|as|an|amos|ais|ai|am|e|es|en|em|emos|eis|ei|o|os|ou|ar|aba|abas|aban|abamos|ava|avas|avam|avamos|aveis" +
|
|
963
|
+
"|ara|aras|aran|aram|aramos|are|ares|aren|arem|aremos|aria|arias|arian|ariam|ariamos|aron|aste|astes|asteis|ase|ases" +
|
|
964
|
+
"|asen|asemos|asse|asses|assem|assemos|asseis|ando|andose|andol[ao]s?|andoles?|andome|andote|ardes|arse|arla|arlas" +
|
|
965
|
+
"|arlo|arlos|arle|arles|arme|arte|arnos|arao|arei|areis|arieis|armos)";
|
|
966
|
+
const ES_ADO = "(?:ado|ada|ados|adas)";
|
|
967
|
+
/** Innocent whole words (folded, a-z) that hold an English-era stem: a hit of that stem lying wholly inside one of
|
|
968
|
+
* them doesn't count. Only that stem: another rule's hit in the same word still does. From the Spanish draft's §3
|
|
969
|
+
* and the Spanish, Portuguese and English word lists and name pairs (2026-10-19). Kike and a bare Paki stay blocked:
|
|
970
|
+
* the slur and the nickname are spelled the same. */
|
|
971
|
+
const ES_LEGACY_OK = Object.entries({
|
|
972
|
+
// bípedo, cuadrúpedo, palmípedo, rompedor, hospedo, pedología, pedorro (qué pedo: NAME_DENY's lookbehind)
|
|
973
|
+
pedo: ["(?:bi|cuadru|palmi|pinni|cirri|veloci|soli|fisi|ali|paralelepi)pedos?", "(?:cor)?rompedor(?:a|es|as)?", "hospedou?",
|
|
974
|
+
"encespedo", "pedolog(?:ia|ias|ica|icas|ico|icos|ic|ical|ies|ist|ists|y)", "pedona(?:l|is|les)",
|
|
975
|
+
"pedorr(?:o|a|os|as|era|eras|ero|eros|eta|etas)", `pedorre(?:${ES_AR}|${ES_ADO})`],
|
|
976
|
+
// denigrar (and English denigrate), nigromante, organigrama
|
|
977
|
+
nigr: [`denigr(?:${ES_AR}|${ES_ADO}|ante|antes|ativ[oa]s?|atori[oa]s?|acion|aciones|acao|acoes|ate|ated|ates|ating` +
|
|
978
|
+
"|ation|ations|ative|ator|ators|atory)",
|
|
979
|
+
"nigroman(?:cia|cias|te|tes|tico|tica|ticos|ticas)", "(?:orga|marco)nigramas?"],
|
|
980
|
+
// conspicuo, perspicuo (and English conspicuous), espícula, espichar, aspic, spiccato
|
|
981
|
+
spic: ["(?:in)?(?:con|per|tran)spicu(?:o|a|os|as|idad|idades|idade|ous|ously|ousness|ity|ities)",
|
|
982
|
+
"e?spicul(?:a|as|ae|ar|ation|ations|e|es|um)", `d?espich(?:${ES_AR}|${ES_ADO}|adela|adelas|el)`, `despic${ES_AR}`,
|
|
983
|
+
"aspics?", "spiccatos?"],
|
|
984
|
+
// retardo, retardar's other forms, retardante (and English retardant), sobretarde; not retard, retarded, retardado
|
|
985
|
+
retard: [`retard(?:${ES_AR}|ante|antes|ador|adora|adores|adoras|acion|aciones|acao|acoes|amento|amentos|amiento` +
|
|
986
|
+
"|amientos|ant|ants|ance|ation|ations)",
|
|
987
|
+
"(?:acarr|afr|arr|corr|decr|desclor|embarr|excr|fr|gr|interpr|marr|xer)etardes", "sobretardes?"],
|
|
988
|
+
paki: ["pakit[oa]s?"], // Pakito, Pakita (Francisco, Francisca)
|
|
989
|
+
adolf: ["adolf(?:it[oa]|in[oa])s?"], // Adolfito, Adolfina
|
|
990
|
+
rapist: ["trapist[ao]s?"], // trapista (Trappist); rapista (a barber, archaic) stays blocked
|
|
991
|
+
hitl: ["xochitls?", "hitless"], // Xóchitl, a common Mexican name; hitless (baseball)
|
|
992
|
+
}).map(([stem, words]) => [stem, new RegExp(`^(?:${words.join("|")})$`)]);
|
|
993
|
+
const ES_OK = new Map(ES_LEGACY_OK);
|
|
994
|
+
/** For the rules matched some other way (SPACED_DENY): the name with each such stem blanked inside
|
|
995
|
+
* the innocent words that hold it ("bípedo" reads "bi ", "PakitoGamer" " toGamer"), camelCase humps read as words. */
|
|
996
|
+
function ptAside(name) {
|
|
997
|
+
const blank = (p) => {
|
|
998
|
+
let f = p.normalize("NFKD").replace(/[\p{M}\p{Cf}]/gu, "").toLowerCase(), hit = false;
|
|
999
|
+
for (const [stem, re] of ES_LEGACY_OK) if (re.test(f)) { f = f.split(stem).join(" "); hit = true; }
|
|
1000
|
+
return hit ? f : p;
|
|
1001
|
+
};
|
|
1002
|
+
return String(name ?? "").replace(/[\p{L}\p{M}\p{Cf}]+/gu, (t) => {
|
|
1003
|
+
const b = blank(t);
|
|
1004
|
+
return b !== t ? b : ptHumps(t).split(" ").map(blank).join("");
|
|
1005
|
+
});
|
|
1006
|
+
}
|
|
1007
|
+
function ptShape(copy, wild) {
|
|
1008
|
+
const s = String(copy ?? ""), latin = /[a-z]/.test(s), starts = new Set(), end = [], spans = [];
|
|
1009
|
+
const words = s.replace(/[^a-z]/gu, (ch) => (/\p{L}/u.test(ch) ? (wild && latin ? "?" : "") : /\p{N}/u.test(ch) ? "" : " "))
|
|
1010
|
+
.split(" ").filter(Boolean);
|
|
1011
|
+
for (let i = 0, at = 0; i < words.length; at += words[i++].length) {
|
|
1012
|
+
starts.add(at);
|
|
1013
|
+
spans.push([at, at + words[i].length, words[i]]);
|
|
1014
|
+
for (let j = 0; j < words[i].length; j++) end[at + j] = at + words[i].length;
|
|
1015
|
+
}
|
|
1016
|
+
return { joined: words.join(""), starts, end, spans };
|
|
1017
|
+
}
|
|
1018
|
+
function ptLegacyUnsafe(rules, copy, humped = copy, wild = false) {
|
|
1019
|
+
// most names hit no rule at all, joined up as they used to be: only the ones that do are looked at word by word
|
|
1020
|
+
const bare = String(copy ?? "").replace(/[^a-z]/g, "");
|
|
1021
|
+
// (with one "?" standing in, a rule's first half or its second half is still there, letter for letter)
|
|
1022
|
+
const odd = wild && bare && /(?![a-z])\p{L}/u.test(copy);
|
|
1023
|
+
const half = (r) => { const h = r.length >> 1; return bare.includes(r.slice(0, h)) || bare.includes(r.slice(h)); };
|
|
1024
|
+
const hits = rules.filter((rule) => (typeof rule === "string" ? bare.includes(rule) || (odd && half(rule)) : rule.test(bare)));
|
|
1025
|
+
if (!hits.length) return false;
|
|
1026
|
+
const shapes = [wild, false].map((w) => {
|
|
1027
|
+
const a = ptShape(copy, w), b = ptShape(humped, w);
|
|
1028
|
+
if (b.joined === a.joined) { for (const at of b.starts) a.starts.add(at); a.spans.push(...b.spans); }
|
|
1029
|
+
return a;
|
|
1030
|
+
});
|
|
1031
|
+
// ...and not where the stem sits inside an innocent word that holds it (ES_LEGACY_OK)
|
|
1032
|
+
const innocent = ({ spans }, i, text) => ES_OK.has(text) && spans.some(([s, e, w]) => s <= i && i + text.length <= e && ES_OK.get(text).test(w));
|
|
1033
|
+
// ...or where the hit takes in two or more single letters spelled out ("xXn.i.g.g.e.rXx", Delve's reading)
|
|
1034
|
+
const spelled = ({ spans }, i, n) => new Set(spans.filter(([s, e]) => e - s === 1 && s >= i && e <= i + n).map(([s]) => s)).size >= 2;
|
|
1035
|
+
const fits = (sh, i, n, text) => (sh.starts.has(i) || i + n <= sh.end[i] || sh.end[i] - i >= 3 || spelled(sh, i, n)) && !innocent(sh, i, text);
|
|
1036
|
+
return hits.some((rule) => {
|
|
1037
|
+
if (typeof rule === "string") {
|
|
1038
|
+
const sh = shapes[0], s = sh.joined;
|
|
1039
|
+
for (let i = 0; i + rule.length <= s.length; i++) {
|
|
1040
|
+
let wilds = 0, ok = true;
|
|
1041
|
+
for (let j = 0; j < rule.length && ok; j++) if (s[i + j] === "?") wilds++; else ok = s[i + j] === rule[j];
|
|
1042
|
+
if (ok && wilds <= 1 && fits(sh, i, rule.length, s.slice(i, i + rule.length))) return true;
|
|
1043
|
+
}
|
|
1044
|
+
return false;
|
|
1045
|
+
}
|
|
1046
|
+
let re = PT_STICKY.get(rule);
|
|
1047
|
+
if (!re) PT_STICKY.set(rule, (re = new RegExp(rule.source, rule.flags.replace(/[gy]/g, "") + "y")));
|
|
1048
|
+
const sh = shapes[1];
|
|
1049
|
+
for (let i = 0; i < sh.joined.length; i++) {
|
|
1050
|
+
re.lastIndex = i;
|
|
1051
|
+
const m = re.exec(sh.joined);
|
|
1052
|
+
if (m && fits(sh, i, m[0].length, m[0])) return true;
|
|
1053
|
+
}
|
|
1054
|
+
return false;
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
/* ---- pt-BR name floor: end ---- */
|
|
1058
|
+
|
|
1059
|
+
/** `hay` contains `needle`, where a "?" in hay matches any one letter, at most once per match. */
|
|
1060
|
+
function looseIncludes(hay, needle) {
|
|
1061
|
+
if (!needle) return false;
|
|
1062
|
+
if (hay.includes(needle)) return true;
|
|
1063
|
+
if (!hay.includes("?")) return false;
|
|
1064
|
+
for (let i = 0; i + needle.length <= hay.length; i++) {
|
|
1065
|
+
let wild = 0, ok = true;
|
|
1066
|
+
for (let j = 0; j < needle.length && ok; j++) { const c = hay[i + j]; if (c === "?") wild++; else if (c !== needle[j]) ok = false; }
|
|
1067
|
+
if (ok && wild <= 1) return true;
|
|
1068
|
+
}
|
|
1069
|
+
return false;
|
|
1070
|
+
}
|
|
1071
|
+
|
|
1072
|
+
/**
|
|
1073
|
+
* Whether a viewer name may reach the stream.
|
|
1074
|
+
* Answers are remembered (the last few thousand names): boards resolve names at draw time, every frame, and a full
|
|
1075
|
+
* check is tens of microseconds.
|
|
1076
|
+
*/
|
|
1077
|
+
const SEEN = new Map();
|
|
1078
|
+
function nameIsSafe(name) {
|
|
1079
|
+
const s = String(name ?? "");
|
|
1080
|
+
let ok = SEEN.get(s);
|
|
1081
|
+
if (ok === undefined) {
|
|
1082
|
+
if (SEEN.size >= 5000) SEEN.clear();
|
|
1083
|
+
SEEN.set(s, (ok = check(s)));
|
|
1084
|
+
}
|
|
1085
|
+
return ok;
|
|
1086
|
+
}
|
|
1087
|
+
/** Read across every separator, but only as the whole word: the slur split anywhere ("an.igger", "Dan_igger", which Delve's
|
|
1088
|
+
* old word-gap reading caught). A stem never is ("Jan Igreja" holds nigr, "Toni Grande" too). */
|
|
1089
|
+
const WHOLE_ACROSS = /n+i+g+g+(?:e+r+|a+)/;
|
|
1090
|
+
/** A letter that isn't a-z (after the fold): a non-Latin one, which the wild and plain readings treat differently. */
|
|
1091
|
+
const NON_LATIN = /(?![a-z])\p{L}/u;
|
|
1092
|
+
/** Signs that are hate symbols on their own: the swastika (卐 卍, the Tibetan ones) and the SS runes (ᛋᛋ, ϟϟ). */
|
|
1093
|
+
const HATE_SYMBOLS = /[\u5350\u534D\u0FD5-\u0FD8]|\u16CB[\s._-]*\u16CB|\u03DF[\s._-]*\u03DF/u;
|
|
1094
|
+
/** Longer than any platform's display name (Twitch 25, TikTok nicknames about 30): a placeholder, and no 200-character
|
|
1095
|
+
* name costs the board milliseconds. */
|
|
1096
|
+
const MAX_CHECKED = 64;
|
|
1097
|
+
function check(s) {
|
|
1098
|
+
const n = s.normalize("NFKC");
|
|
1099
|
+
if ([...n].length > MAX_CHECKED || HATE_SYMBOLS.test(n)) return false;
|
|
1100
|
+
if (!checkOne(s)) return false;
|
|
1101
|
+
const runs = [...(s.match(ENCLOSED_RUN) || []), ...(s.match(REGIONAL_RUN) || []).filter((r) => r.replace(/[\s._-]/g, "").length >= 12)];
|
|
1102
|
+
return runs.every((r) => checkOne(unEnclose(r)));
|
|
1103
|
+
}
|
|
1104
|
+
function checkOne(s) {
|
|
1105
|
+
if (BIDI.test(s)) return false;
|
|
1106
|
+
if (RAW_DENY.some((re) => re.test(s.toLowerCase()))) return false;
|
|
1107
|
+
// dots, underscores, dashes, spaces and invisible characters between the digits don't hide a code ("14.88")
|
|
1108
|
+
if (DIGITS_DENY.test(asciiDigits(s).replace(/[\p{Cf}\s._\-]/gu, ""))) return false;
|
|
1109
|
+
const fold = (x) => leet(letters(x));
|
|
1110
|
+
/** Every I/1/|/! reading, folded; the camelCase-humped copy reuses them when humps change nothing. */
|
|
1111
|
+
const folded = (x) => readings(x).map(fold), withHumps = (x, plain) => { const hx = ptHumps(x); return hx === x ? plain : folded(hx); };
|
|
1112
|
+
// pt-BR: one copy with digits as separators (puta_123), and each reading with leetspeak folded (p0rr4)
|
|
1113
|
+
const h = ptHumps(s);
|
|
1114
|
+
if (ptUnsafe([letters(h), ...folded(h)])) return false;
|
|
1115
|
+
// NAME_DENY on the separator-stripped copy, but never from the middle of one word into the next ("Esqueço o nome"),
|
|
1116
|
+
// with an allowed whole word set aside (exempt), and camelCase humps as word starts too. A letter that folds to
|
|
1117
|
+
// nothing Latin, in a name that has Latin letters, is read both ways: as a "?" (any one letter: "hi?ler", Rip Night's
|
|
1118
|
+
// wild reading) and as nothing at all ("nのiのgger", "nㅤiㅤgger": the other families' reading). Either one blocks.
|
|
1119
|
+
const kept = exempt(s), keptPlain = folded(kept), keptHumped = withHumps(kept, keptPlain);
|
|
1120
|
+
for (const [i, l] of keptPlain.entries()) {
|
|
1121
|
+
if (ptLegacyUnsafe(NAME_DENY, l, keptHumped[i], true)) return false;
|
|
1122
|
+
if (NON_LATIN.test(l) && ptLegacyUnsafe(NAME_DENY, l, keptHumped[i], false)) return false;
|
|
1123
|
+
if ([...l.split(/[^a-z]+/), ...ptWords(l)].some((w) => w && WORD_DENY.some((re) => re.test(w)))) return false;
|
|
1124
|
+
}
|
|
1125
|
+
// SPACED_DENY, with the innocent words that hold a stem set aside (bípedo, Pakito: ptAside), humps as breaks or not
|
|
1126
|
+
const aside = ptAside(s), asidePlain = folded(aside), asideHumped = withHumps(aside, asidePlain);
|
|
1127
|
+
for (const x of asidePlain === asideHumped ? asidePlain : [...asidePlain, ...asideHumped]) {
|
|
1128
|
+
if (SPACED_DENY.some((re) => re.test(x.replace(/[^a-z]+/g, " ").trim()))) return false;
|
|
1129
|
+
if (WHOLE_ACROSS.test(x.replace(/[^a-z]+/g, ""))) return false;
|
|
1130
|
+
}
|
|
1131
|
+
return true;
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/** What to draw for a chatter. Unsafe names are not shown at all rather than starred out: a censored slur is still the
|
|
1135
|
+
* slur, and still on the stream. */
|
|
1136
|
+
function displayName(name) {
|
|
1137
|
+
if ([...String(name || "").normalize("NFKC")].length > MAX_CHECKED) return "a viewer"; // the cap holds before the cut
|
|
1138
|
+
const n = String(name || "").slice(0, MAX_NAME);
|
|
1139
|
+
return nameIsSafe(n) ? n : "a viewer";
|
|
1140
|
+
}
|
|
1141
|
+
|
|
1142
|
+
/** A name's words, the way the pt-BR palavra entries see them (accents, look-alikes and camelCase humps folded; one copy
|
|
1143
|
+
* with digits as separators, one per I/1/| reading with leetspeak folded; a run of single letters is one word). Hot
|
|
1144
|
+
* Seat's rules.js checks the blocklist stems that Portuguese words hold against these, whole. */
|
|
1145
|
+
function nameWords(name) {
|
|
1146
|
+
const h = ptHumps(name);
|
|
1147
|
+
return [letters(h), ...readings(h).map((x) => leet(letters(x)))].map(ptWords);
|
|
1148
|
+
}
|
|
1149
|
+
return { nameIsSafe, nameWords };
|
|
1150
|
+
})();
|
|
1151
|
+
/* ---- LEGACY: end ---- */
|