d263c7bf48
- GameGlobal.js: keep upstream SERVER_URL with /ws suffix - en.js/zh.js: merge both settings.nickname and settings.profile keys - SettingsScene.js: keep both nickname row and profile button - server/index.js: merge express app + content security proxy with noServer WebSocket mode and path validation - Add .gitignore for node_modules and .codebuddy
133 lines
3.6 KiB
JavaScript
133 lines
3.6 KiB
JavaScript
/**
|
|
* Sensitive Words Dictionary
|
|
* Provides sensitive word lists for content security filtering.
|
|
* This is the server-side master word list that gets served to clients.
|
|
*
|
|
* Categories:
|
|
* - politics: Politically harmful content
|
|
* - pornography: Pornographic and obscene content
|
|
* - gambling: Gambling and illegal betting content
|
|
* - violence: Violent and threatening content
|
|
* - abuse: Abusive and insulting language
|
|
* - fraud: Fraud and scam content
|
|
* - other: Other regulated content
|
|
*/
|
|
|
|
const SENSITIVE_WORDS = {
|
|
politics: [
|
|
// Politically sensitive terms (representative samples)
|
|
'颠覆国家', '推翻政权', '分裂国家', '恐怖组织', '极端主义',
|
|
'反动', '暴乱', '煽动颠覆', '分裂势力', '恐怖袭击',
|
|
'邪教组织', '法轮', '法轮功', '台独', '藏独', '疆独',
|
|
],
|
|
|
|
pornography: [
|
|
// Pornographic and obscene terms (representative samples)
|
|
'色情', '淫秽', '裸体', '性交', '卖淫',
|
|
'嫖娼', '成人电影', '情色', '黄色视频', '一夜情',
|
|
'援交', '约炮', '色诱', '露点', '性服务',
|
|
],
|
|
|
|
gambling: [
|
|
// Gambling related terms (representative samples)
|
|
'赌博', '赌场', '下注', '赌资', '博彩',
|
|
'六合彩', '时时彩', '赌球', '网络赌', '百家乐',
|
|
'老虎机', '扑克赌', '赌狗', '开盘下注', '庄家赔率',
|
|
],
|
|
|
|
violence: [
|
|
// Violence related terms (representative samples)
|
|
'杀人', '砍人', '捅死', '爆炸装置', '自制炸弹',
|
|
'灭门', '血腥屠杀', '残忍杀害', '暴力袭击', '砍杀',
|
|
],
|
|
|
|
abuse: [
|
|
// Abusive language (representative samples)
|
|
'傻逼', '操你', '妈的', '去死', '废物',
|
|
'滚蛋', '贱人', '狗日的', '草泥马', '脑残',
|
|
'白痴', '弱智', '猪头', '王八蛋', '混蛋',
|
|
],
|
|
|
|
fraud: [
|
|
// Fraud and scam terms (representative samples)
|
|
'代开发票', '虚假投资', '传销', '诈骗', '骗钱',
|
|
'刷单', '套现', '洗钱', '假币', '传销组织',
|
|
],
|
|
|
|
other: [
|
|
// Other regulated terms
|
|
'代孕', '买卖器官', '毒品', '吸毒', '走私',
|
|
'枪支', '管制刀具', '假药', '违禁品',
|
|
],
|
|
};
|
|
|
|
/**
|
|
* Get all sensitive words as a flat array.
|
|
* @returns {string[]}
|
|
*/
|
|
function getAllWords() {
|
|
return Object.values(SENSITIVE_WORDS).flat();
|
|
}
|
|
|
|
/**
|
|
* Get words grouped by category.
|
|
* @returns {object}
|
|
*/
|
|
function getWordsByCategory() {
|
|
return { ...SENSITIVE_WORDS };
|
|
}
|
|
|
|
/**
|
|
* Get the total count of words.
|
|
* @returns {number}
|
|
*/
|
|
function getWordCount() {
|
|
return getAllWords().length;
|
|
}
|
|
|
|
/**
|
|
* Check if a text contains any sensitive words.
|
|
* @param {string} text - Text to check
|
|
* @returns {{ hasViolation: boolean, matchedWords: string[], categories: string[] }}
|
|
*/
|
|
function checkText(text) {
|
|
if (!text || typeof text !== 'string') {
|
|
return { hasViolation: false, matchedWords: [], categories: [] };
|
|
}
|
|
|
|
const matchedWords = [];
|
|
const categories = new Set();
|
|
const lowerText = text.toLowerCase();
|
|
|
|
for (const [category, words] of Object.entries(SENSITIVE_WORDS)) {
|
|
for (const word of words) {
|
|
if (lowerText.includes(word.toLowerCase())) {
|
|
matchedWords.push(word);
|
|
categories.add(category);
|
|
}
|
|
}
|
|
}
|
|
|
|
return {
|
|
hasViolation: matchedWords.length > 0,
|
|
matchedWords: [...new Set(matchedWords)],
|
|
categories: [...categories],
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Get the version/timestamp of the word list for cache validation.
|
|
* @returns {string}
|
|
*/
|
|
function getVersion() {
|
|
return '2026-05-11-v1';
|
|
}
|
|
|
|
module.exports = {
|
|
SENSITIVE_WORDS,
|
|
getAllWords,
|
|
getWordsByCategory,
|
|
getWordCount,
|
|
checkText,
|
|
getVersion,
|
|
}; |