npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

gbdetector

v1.1.2

Published

GbDetector is an advanced text analysis module designed to identify gambling-related content through sophisticated pattern matching and text processing techniques.

Downloads

26

Readme

🎰 GbDetector Documentation

📌 Overview

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.

🎯 Purpose

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.

🌟 Key Features

  • 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 🔍

🧭 Architecture Flow Diagram

[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]

🧠 Detection Algorithm

  1. Preprocessing:

    • Convert newlines to spaces
    • Normalize whitespace
    • Add spaces around dots
  2. Initial Checks:

    • Detect excessive non-alphanumeric ("garbage") characters
    • Identify abnormal repetition patterns
    • Detect suspicious URL patterns
    • Detect suspicious code or emoji sequences
  3. Evasion Technique Analysis:

    • Identify evasion methods
    • Score based on detected techniques
  4. Contextual Indicator Detection:

    • Analyze text context for gambling cues
    • Score based on found indicators
  5. Contact Info Extraction:

    • Identify and extract potential contact information
  6. Text Normalization:

    • Remove diacritics and standardize characters
    • Reconstruct intentionally split words
    • Merge numbers with preceding words
  7. Language Pattern Detection:

    • Apply language-specific pattern checks
    • Score based on matches
  8. Domain Matching:

    • Check domains in text against blocklist
    • Consider domain format variations
  9. 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
  10. Supporting Keyword Analysis:

    • Detect supporting keywords post-pattern match
    • Add bonus based on keyword match count
  11. Content Length & Complexity Analysis:

    • Count metrics like word/character totals, average word length
    • Identify spammy gambling content characteristics
  12. Final Evaluation:

    • Normalize checkpoint scores by sensitivity factor
    • Determine confidence level: none, low, medium, high
    • Generate a detailed analysis report if requested

🧩 Core Functions

detect(text = "", options = {})

Main function for detecting gambling patterns in text.

Parameters:

  • text (string): The text to be analyzed

  • options (object): Configuration options

    • keywords: Pattern terms to detect (e.g., site names)
    • supportKeywords: Supporting keyword list
    • domains: List of domains to detect
    • allowlist: Whitelisted terms
    • sensitivityLevel: Detection sensitivity (1–5, default 3)
    • includeAnalysis: Include detailed analysis in results
    • detectRepetition, detectUrlPatterns, detectEvasionTechniques, detectContextualIndicators: Boolean toggles for specific detection types
    • extractContactInfo: Whether to extract contact info
    • language: Language selection ('en', 'id', 'all')
    • debug: Show debug info

Returns: An object with detection results:

  • isGambling (boolean): Whether gambling content is detected
  • confidence (string): "none", "low", "medium", or "high"
  • checkpoint (number): Numerical detection score
  • details (string): Human-readable explanation
  • comment (string): Original analyzed text
  • analysis (object, optional): Detailed analysis info

🧹 Text Processing

  • cleanText(text) – Normalize and clean text
  • cleanWeirdPatterns(text) – Remove odd spacing and punctuation
  • reconstructSeparatedWords(text) – Reconstruct deliberately split words
  • mergeTextWithTrailingNumbers(text) – Merge numbers trailing words

🧠 Detection Logic

  • isMostlyAsciiGarbage(text, threshold = 0.45) – Detect non-alphanumeric spam
  • hasAbnormalRepetition(text) – Detect character/pattern repetition
  • hasSuspiciousUrlPatterns(text) – Detect obfuscated URLs
  • hasSuspiciousCodeSequences(text) – Detect suspicious symbols/emoji
  • convertCommentFixed(comment, ignoreLastDigits = 0) – Convert symbols to characters
  • fuzzySearch(keywords, text) – Perform fuzzy keyword match

🔬 Advanced Analysis

  • analyzeEvasionTechniques(text)
  • detectContextualGamblingIndicators(text)
  • extractContactInfos(text)
  • detectLanguageSpecificPatterns(text, language)

📐 Pattern Matching

  • createPatternRegex(terms, loose = false) – Create RegExp pattern
  • TinyPatternRegex(terms) – Create focused RegExp pattern

🧮 Mathematical Formulas

🎯 Confidence Threshold Calculation

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)
}

🧠 Keyword Bonus Calculation

keywordBonus = Math.min(1.5, 0.03 * (keywordMatchCount/2) + 0.7)

🧹 Garbage Character Ratio

garbageRatio = numberOfGarbageCharacters / totalTextLength
isGarbage = garbageRatio >= threshold (default 0.45)

💡 Usage Example

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
});

🃏 Default Keywords

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.

📄 License

MIT License © 2025 Ramsyan-Tungga

✅ Conclusion

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.