Skip to content

Add DriveThruCards Integration#367

Draft
bwsinger wants to merge 15 commits intochilli-axe:masterfrom
bwsinger:drivethrucards
Draft

Add DriveThruCards Integration#367
bwsinger wants to merge 15 commits intochilli-axe:masterfrom
bwsinger:drivethrucards

Conversation

@bwsinger
Copy link
Copy Markdown

@bwsinger bwsinger commented Jan 28, 2026

Description

This PR adds support for automating card orders on DriveThruCards, including PDF generation and browser-based order submission. It's not fully polished yet. I still plan to clean up the Selenium automation and add more tests and better documentation. I started the PR now because it is in an MVP state and I wanted to prompt discussion on the methods I used.

Important

This PR adds a free Command Line Tool called Ghostscript as a dependency to convert PDFs to DriveThruCards' desired format: "PDF/X-1a 2003". This format is typically only producible by Adobe Acrobat and other such professional applications. To avoid this paid and inconsistent dependency, I instead opted to use Ghostscript to convert the existing PDF output to something DTC compatible. To avoid having to bundle OS-specific binaries of Ghostscript with autofill, I instead elected to add a step at the beginning of the DriveThruCards option in the CLI to download and install the Ghostscript command line for the user. Unfortunately, there are no Python libraries that can do the same job.

Summary

  • Add DriveThruCards as a new target site with full order automation
  • Generate print-ready PDFs with correct dimensions (2.73" x 3.71" for Premium Euro Poker with bleed)
  • Convert PDFs to PDF/X-1a format using Ghostscript with CMYK color profile
  • Automate the entire order flow from login to checkout

Changes

PDF Generation:

  • Export cards to PDF with DriveThruCards-specific dimensions
  • Integrate Ghostscript for PDF/X-1a conversion with USWebCoatedSWOP ICC profile
  • Bundle ICC profile and placeholder cover image with the tool

Browser Automation:

  1. Handle Cloudflare challenge detection
  2. Automate login flow with manual fallback
  3. Navigate through Publisher Tools → Product Setup
  4. Fill product form (title, price, cover image, checkboxes)
  5. Upload PDF via Dropzone.js with multiple fallback strategies
  6. Navigate through checkout flow, stopping before payment

Checklist

  • I have installed pre-commit and installed the hooks with pre-commit install before creating any commits.
  • I have updated any related tests for code I modified or added new tests where appropriate.
  • I have manually tested my changes as follows:
    • On Mac I've manually went from real XML order from mpcfill.com to PDF generation to Selenium order automation.
    • Selenium automation isn't very smooth or robust yet, but it does get there.
  • I have updated any relevant documentation or created new documentation where appropriate.

- Automate login, product setup, PDF upload, and checkout navigation
- Fix card dimensions to 2.73" x 3.71" for Premium Euro Poker with bleed
- Use Ghostscript -dNOSAFER flag for PDF/X-1a conversion
- Add placeholder cover image for product form
- Replace sleep timers with dynamic element waits
@bwsinger bwsinger marked this pull request as draft January 30, 2026 07:56
@ndepaola
Copy link
Copy Markdown
Collaborator

thanks - i haven't looked at the code yet but this sounds exciting!

i'll look into the PDF formatting issue a bit and will report back if i find anything. not very keen to bundle/install a third-party command tool alongside autofill, i'd much prefer for the autofill binary to be totally standalone.

JPEG has a 64KB limit for XMP data in a single APP1 segment. Some source
images have XMP data exceeding this limit, causing "XMP data is too long"
errors when saving. Since XMP is purely metadata and doesn't affect the
visual content, we strip it before saving.
- Replace standard selenium Chrome driver with undetected-chromedriver
- Add aggressive polling (500ms) for Cloudflare challenge detection
- Add auto-click attempt for Turnstile checkbox in iframe
- Fix login modal selector to target correct link
- Remove set_network_conditions calls (potential detection vector)
- Add setuptools dependency for Python 3.13 compatibility
- Remove unused ChromeOptions import
- Add _detect_chrome_version() to query installed Chrome version
- Support macOS, Windows, and Linux version detection
- Pass detected version to undetected-chromedriver to fix version mismatch
- Add JavaScript patches to hide automation traces (webdriver property,
  chrome object, plugins, languages, ChromeDriver detection variables)
- Add --disable-blink-features=AutomationControlled flag
- Remove ineffective focus workaround that caused unnecessary delays
…ring polling

Selenium's implicit wait (5s) was causing long delays between solving
the Cloudflare CAPTCHA and clicking the login button. Fixed by
temporarily disabling implicit wait in polling methods:
- _try_click_turnstile_checkbox()
- _is_cloudflare_challenge_active()
- _is_site_loaded()
- is_dtc_user_authenticated()
- click_element_polling()
These methods were part of a failed attempt to bypass bot detection
by triggering visibility/focus events. They are no longer called:
- _simulate_human_behavior()
- _trigger_visibility_change_via_minimize()
- _perform_tab_switch_workaround()
- _perform_login_focus_workaround()

Also added commit/cleanup workflow guidance to CLAUDE.md.
The 'Click here after uploading your files' button starts with an onclick
handler that shows an error and returns false. After server-side upload
validation, the page JS replaces this with the actual form submit handler.
Previously the click fired before this replacement, causing the page to
not navigate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants