Extension for Chromium-based browsers to automatically solve and autofill captchas on NEPSE TMS sites.
- Strictest TypeScript: Migrated to
@tsconfig/strictestfor maximum type safety and industry-standard best practices. - Biome Integration: Switched to Biome for blazing-fast linting and formatting, replacing ESLint/Prettier.
- Automated Releases: Integrated GitHub Actions to automatically build, package, and release both Chrome and Firefox extensions on every version tag.
- Fixed Load Issues: Corrected manifest bundling to resolve "Could not load evaluate.js" errors in Brave/Chrome.
- High-Precision Model: Upgraded from 5 to 9-factor spatial analysis. Includes quadrant-level density checks for significantly better character recognition.
- Improved Resiliency: Increased automatic re-solve attempts (up to 10) for distorted captchas.
- Instant Clear: Input fields now clear immediately upon refresh to prevent stale data.
- Race Condition Fix: Implemented request ID tracking to ensure only the latest captcha result is applied.
TMS Captcha Solver is a lightweight browser extension that uses a custom spatial density analysis model to identify characters in NEPSE TMS captchas. It bypasses background noise, segments the image, and matches patterns against a pre-trained dataset in real-time, all within your browser.
🔍 Technical Deep Dive: How it Works Under the Hood
The extension first captures the captcha image as a Base64 URI. It performs background subtraction using a reference "empty" captcha image to isolate character pixels from the noisy background. The resulting image is then thresholded (binarized) for cleaner analysis.
Using a vertical scanning algorithm, the system identifies "empty" columns to split the single captcha strip into individual character matrices. It handles both Bold and Slim font variants used by TMS.
Instead of complex OCR or Neural Networks, this project uses a high-performance feature extraction approach. Each character is evaluated across 9 distinct factors:
- Global Density: Average pixel value of the whole character.
- Bisectional Density: Average pixel values of the Left/Right and Top/Bottom halves.
- Quadrant Density: Average pixel values of the Top-Left, Top-Right, Bottom-Left, and Bottom-Right quadrants.
- Aspect Ratio: The width-to-height ratio of the character container.
The extracted 9-factor vector is compared against a local dataset (bold_data.json and slim_data.json). It calculates a Weighted Euclidean Distance between the current character and every known character in the dataset.
- The factor weights (
FACTORS) are tuned to prioritize certain spatial features (like quadrant density) over others. - The character with the lowest "error" (distance) is selected, provided it meets a confidence threshold.
- MutationObserver: Monitors the DOM for captcha image refreshes.
- Request Tracking: Uses incrementing Request IDs to prevent race conditions where a slow solve for an old captcha might overwrite a newer one.
- Input Simulation: Dispatches native
inputevents after filling the field to ensure the underlying React/Angular state of the TMS site is updated.
- Download the latest
tmscaptcha-chrome-[version].zipfrom the Releases page. - Extract the ZIP file to a folder.
- Open Brave/Chrome and go to
brave://extensionsorchrome://extensions. - Enable Developer mode.
- Click Load unpacked and select the extracted folder.
If you want to build the extension manually:
- Clone the repository:
git clone https://github.com/scuba3198/tms-captcha.git cd tms-captcha - Install dependencies:
npm install
- Build the extension:
- Chrome/Brave:
npm run build:chrome - Firefox:
npm run build:firefox - Both:
npm run build:all
- Chrome/Brave:
We use Biome for code quality:
npm run lint # Check for linting/formatting issues
npm run format # Automatically fix issuesAfter building, click Load unpacked in your browser's extension settings and select the dist-chrome directory.
- Get your API credentials from AMO's API Keys page.
- Set environment variables:
export MOZILLA_JWT_ISSUER="your-jwt-issuer" export MOZILLA_JWT_SECRET="your-jwt-secret"
- Run the publish command:
npm run publish:firefox
Developed with ❤️ for the NEPSE community.
