Skip to content

Build extension js#337

Closed
vict0rsch wants to merge 7 commits intorefactor-es-modulesfrom
build-extension-js
Closed

Build extension js#337
vict0rsch wants to merge 7 commits intorefactor-es-modulesfrom
build-extension-js

Conversation

@vict0rsch
Copy link
Copy Markdown
Owner

No description provided.

Replaces plain puppeteer with puppeteer-extra and its stealth plugin in
test/browser.js and test/citations-scraper.js. Removes the custom
PuppeteerAgent user-agent string. Includes rebuilt bundles.

Made-with: Cursor
Two paste-in-console scripts for the options page of the dev browser:
- manual-open-urls.js: opens each abstract URL sequentially, polls
  storage for new papers (3s timeout per page)
- manual-verify-urls.js: checks stored papers against urls.json and
  reports missing sources

Made-with: Cursor
@vict0rsch vict0rsch marked this pull request as draft April 12, 2026 19:01
vict0rsch added a commit that referenced this pull request Apr 12, 2026
- fix: chemrxiv parsing (add doi pattern)
- feat: puppeteer-extra with stealth plugin
- test: add manual console scripts for URL testing
- chore: Prettier formatting (trailing commas, ternary alignment)
- fix: ar5iv modal cancel button (JS listener instead of onclick)
- fix: popup URL detection for /action/ paths
- fix: .catch() on initSyncAndState for graceful failure
- fix: try/catch around sampleAsciiArt with fallback
- fix: try/catch around makePaper with logError

Made-with: Cursor
vict0rsch added a commit that referenced this pull request Apr 12, 2026
* chore: cherry-pick non-build changes from build-extension-js PR #337

- fix: chemrxiv parsing (add doi pattern)
- feat: puppeteer-extra with stealth plugin
- test: add manual console scripts for URL testing
- chore: Prettier formatting (trailing commas, ternary alignment)
- fix: ar5iv modal cancel button (JS listener instead of onclick)
- fix: popup URL detection for /action/ paths
- fix: .catch() on initSyncAndState for graceful failure
- fix: try/catch around sampleAsciiArt with fallback
- fix: try/catch around makePaper with logError

Made-with: Cursor

* feat: migrate build system from Rollup to WXT

- Replace Rollup + web-ext + Python release script with WXT
- Create wxt.config.js with manifest, aliases, and HTML include plugin
- Restructure entry points into src/entrypoints/ (WXT convention)
- Install jquery/select2 via npm, create jquery-setup.js for globals
- Move static assets to public/ (CSS, data JSON, theme.js, icons)
- Update chrome.runtime.getURL paths for WXT output structure
- Wrap background.js in defineBackground() for WXT compatibility
- Wrap content_script.js in defineContentScript() with CSS imports
- Import debug.js module in all HTML entry points for PMDebug global
- Update test paths to use .output/chrome-mv3/ directory
- Simplify CI: single npm run build produces Chrome + Firefox
- Update package.json scripts for WXT dev/build/zip commands
- Remove rollup.config.js, committed bundles, vendored jQuery/select2
- Add .output/ and .wxt/ to .gitignore

Made-with: Cursor

* fix: resolve ESM timing issues in popup tests after WXT migration

With WXT's ESM bundling, popup module loading is async, so tests
that reload the popup must wait for full initialization before
interacting with UI elements.

- Add window.__pmPopupReady flag set at end of popupMain() to signal
  when all click handlers are attached (including early return path)
- Add .catch() on fire-and-forget popupMain() call to set flag on error
- Update test helpers (waitForPopupReady, setPreference,
  setupPopupWithMockedTab, setupPageWithData, setPreferencesAndReload)
  to wait for __pmPopupReady instead of just networkidle0 or PMDebug
- Fix dark mode test: check for dark.css instead of dark.min.css
  (WXT serves unminified CSS in public/)
- Fix select2 initialization in jquery-setup.js for ESM default export

Made-with: Cursor

* docs: rewrite contributing.md for WXT build system

- Replace all Rollup references with WXT equivalents
- Add "What is WXT?" section explaining the build tool
- Document new build commands (dev, build, zip for both browsers)
- Add step-by-step "Loading the extension" instructions for Chrome/Firefox
- Explain WXT entry point convention (src/entrypoints/)
- Document jquery-setup.js, HTML includes, static assets in public/
- Update file structure tree to reflect current layout
- Simplify PMDebug docs (available in all pages, not dev-only)
- Clean up Tests section (remove duplication, update commands)
- Fix setPreferencesAndReload to wait for popup readiness after reload

Made-with: Cursor

* chore: run prettier on src/ and fix invalid HTML

Format all files in src/ with prettier. Fix invalid HTML that
prettier couldn't parse: remove void element end tags (</input>),
replace <p> tags wrapping block elements (<ul>, <ol>) with <div>.

Made-with: Cursor

* chore: change build output directory from .output to dist/

Made-with: Cursor

* refactor: eliminate entrypoint code duplication

src/background/background.js and src/content_scripts/content_script.js
now export initBackground() and initContentScript() respectively.
The WXT entrypoints are reduced to thin wrappers that call these
functions, making the originals the single source of truth.

Also fills the contributing.md Prettier section and updates the
entrypoints documentation to reflect the new structure.

Made-with: Cursor

* fix: three critical runtime bugs

- bibMatcher: fix broken options link (remove relative path prefix so
  WXT-flattened output resolves correctly)
- parsers/makePaper: re-throw 'Unknown paper source' errors instead of
  swallowing them silently, preserving the intentional failure signal
- parsers/findCellPii: guard against undefined venue when no Cell
  journal matches the parsed ISSN (prevents TypeError on .split())

Made-with: Cursor

* chore: clean up dead code, deps, and minor fixes

- Remove 12 Rollup/Babel/web-ext devDependencies (dead since rollup.config.js deleted)
- Delete duplicate src/data/ JSON files (public/data/ is the runtime source)
- Delete dead src/shared/js/theme.js (replaced by public/theme.js with correct WXT paths)
- Derive __DEV__ from WXT build command instead of hardcoding false
- Tighten popup URL guard: pathname.startsWith("/action") instead of broad href.includes
- Sanitize path separators in download filename to prevent directory traversal

Made-with: Cursor

* chore: apply Prettier formatting

Made-with: Cursor

* chore: ignore logs

* fix: missing css & feedback in dev mode

* fix: regenerate package-lock.json for npm ci compatibility

Made-with: Cursor
@vict0rsch vict0rsch closed this Apr 12, 2026
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.

1 participant