GbDetector is an advanced text analysis module designed to identify gambling-related content through pattern matching and sophisticated text processing. It is encapsulated in an Immediately Invoked Function Expression (IIFE) to prevent global namespace pollution, offering a clean API for text analysis.
This module assists in detecting potential gambling-related content in text, making it useful for content moderation, compliance monitoring, and filtering systems. It leverages various detection mechanisms to identify both overt and obfuscated gambling-related text.
- Text normalization and cleaning โจ
- Detection of obfuscated gambling terminology ๐ต๏ธโโ๏ธ
- Pattern matching for gambling-related keywords ๐ฒ
- Leet-speak and character substitution handling ๐ค
- URL pattern detection ๐
- Custom keyword list and blocklist support ๐
- Evasion technique detection ๐งฉ
- Contextual indicator analysis ๐
- Contact info extraction ๐
- Multi-language support ๐
- Fuzzy search detection ๐
[INPUT TEXT] โ [INITIAL PREPROCESSING]
โ
[GARBAGE/REPETITION CHECK] โ [URL PATTERN CHECK]
โ
[TEXT NORMALIZATION] โ [WORD RECONSTRUCTION]
โ
[NUMBER MERGING] โ [BLOCKLIST CHECK]
โ
[PATTERN MATCHING] โ [LEET-SPEAK CONVERSION]
โ
[KEYWORD MATCHING] โ [CONFIDENCE SCORING]
โ
[OUTPUT RESULT]
-
Preprocessing:
- Convert newlines to spaces
- Normalize whitespace
- Add spaces around dots
-
Initial Checks:
- Detect excessive non-alphanumeric ("garbage") characters
- Identify abnormal repetition patterns
- Detect suspicious URL patterns
- Detect suspicious code or emoji sequences
-
Evasion Technique Analysis:
- Identify evasion methods
- Score based on detected techniques
-
Contextual Indicator Detection:
- Analyze text context for gambling cues
- Score based on found indicators
-
Contact Info Extraction:
- Identify and extract potential contact information
-
Text Normalization:
- Remove diacritics and standardize characters
- Reconstruct intentionally split words
- Merge numbers with preceding words
-
Language Pattern Detection:
- Apply language-specific pattern checks
- Score based on matches
-
Domain Matching:
- Check domains in text against blocklist
- Consider domain format variations
-
Multi-pass Pattern Matching:
- Apply standard and custom regex patterns
- Detect with varying strictness levels
- Convert leet-speak with adjustable digit ignore
- Perform fuzzy matching for obfuscated terms
-
Supporting Keyword Analysis:
- Detect supporting keywords post-pattern match
- Add bonus based on keyword match count
-
Content Length & Complexity Analysis:
- Count metrics like word/character totals, average word length
- Identify spammy gambling content characteristics
-
Final Evaluation:
- Normalize checkpoint scores by sensitivity factor
- Determine confidence level: none, low, medium, high
- Generate a detailed analysis report if requested
Main function for detecting gambling patterns in text.
Parameters:
-
text
(string): The text to be analyzed -
options
(object): Configuration optionskeywords
: Pattern terms to detect (e.g., site names)supportKeywords
: Supporting keyword listdomains
: List of domains to detectallowlist
: Whitelisted termssensitivityLevel
: Detection sensitivity (1โ5, default 3)includeAnalysis
: Include detailed analysis in resultsdetectRepetition
,detectUrlPatterns
,detectEvasionTechniques
,detectContextualIndicators
: Boolean toggles for specific detection typesextractContactInfo
: Whether to extract contact infolanguage
: Language selection ('en', 'id', 'all')debug
: Show debug info
Returns: An object with detection results:
isGambling
(boolean): Whether gambling content is detectedconfidence
(string): "none", "low", "medium", or "high"checkpoint
(number): Numerical detection scoredetails
(string): Human-readable explanationcomment
(string): Original analyzed textanalysis
(object, optional): Detailed analysis info
cleanText(text)
โ Normalize and clean textcleanWeirdPatterns(text)
โ Remove odd spacing and punctuationreconstructSeparatedWords(text)
โ Reconstruct deliberately split wordsmergeTextWithTrailingNumbers(text)
โ Merge numbers trailing words
isMostlyAsciiGarbage(text, threshold = 0.45)
โ Detect non-alphanumeric spamhasAbnormalRepetition(text)
โ Detect character/pattern repetitionhasSuspiciousUrlPatterns(text)
โ Detect obfuscated URLshasSuspiciousCodeSequences(text)
โ Detect suspicious symbols/emojiconvertCommentFixed(comment, ignoreLastDigits = 0)
โ Convert symbols to charactersfuzzySearch(keywords, text)
โ Perform fuzzy keyword match
analyzeEvasionTechniques(text)
detectContextualGamblingIndicators(text)
extractContactInfos(text)
detectLanguageSpecificPatterns(text, language)
createPatternRegex(terms, loose = false)
โ Create RegExp patternTinyPatternRegex(terms)
โ Create focused RegExp pattern
sensitivityFactor = Math.max(1, Math.min(5, sensitivityLevel)) / 3
confidenceThresholds = {
low: Math.max(0.45, 0.5 * sensitivityFactor),
medium: Math.max(0.9, 0.8 * sensitivityFactor),
high: Math.max(1.2, 2.5 * sensitivityFactor)
}
keywordBonus = Math.min(1.5, 0.03 * (keywordMatchCount/2) + 0.7)
garbageRatio = numberOfGarbageCharacters / totalTextLength
isGarbage = garbageRatio >= threshold (default 0.45)
const examples = [
"sl0t88 maxwin guaranteed win!",
"J4ckp0t Zeus99 trusted - sign up now!",
"c a s i n o online with credit & e-wallet deposit",
"best online gambling site slot gacor maxwin today",
"Get rich quick with winning bets at my-gambling-site.com",
"This is a normal sentence with no gambling content.",
"Z.e.u.s g.a.c.o.r m.a.x.w.i.n",
"j*u*d*i o*n*l*i*n*e biggest site"
];
const customConfig = {
keywords: ["win", "maxwin", "deposit", "withdraw", "gacor"],
supportKeywords: ["jp", "jackpot", "slot", "judi", "casino"],
domains: ["scamsite.com", "badword"],
allowlist: ["normal", "common"],
sensitivityLevel: 3,
includeAnalysis: true,
detectRepetition: true,
detectUrlPatterns: true,
detectEvasionTechniques: true,
detectContextualIndicators: true,
extractContactInfo: true,
language: 'all',
debug: true
};
console.log("=== TESTING EXAMPLES ===");
examples.forEach((example, index) => {
console.log(`\nExample ${index + 1}: "${example}"`);
// run detection logic here
});
GbDetector comes with a comprehensive set of default keywords for various gambling-related terms in both English and Indonesian:
๐ Primary Keywords:
[
"slot", "casino", "jack", "zeus", "scatter", "toto", "judol", "jodol",
"poker", "roulette", "betting", "gamble", "joker"
]
๐ ๏ธ Supporting Keywords:
- English gambling terms:
wdp
,wd
,win
,happy
,joyful
,rich
,trustworthy
,lucky
,trust
, etc. - Indonesian gambling terms:
menang
,senang
,gacor
,gembira
,kaya
,pasti dapat
,bangga
,panen
, etc.
MIT License ยฉ 2025 Ramsyan-Tungga
The GbDetector module offers a powerful solution for identifying gambling-related content in text, even when obfuscated. By combining various detection techniques and offering extensive configuration options, the module achieves high accuracy while minimizing false positives. Its modular design ensures easy integration into different systems requiring content moderation or filtering capabilities.