Fix userscript install URL and dynamic loading#1
Conversation
📝 WalkthroughWalkthroughThis PR refactors the userscript initialization mechanism from a retry-based polling approach to a mutation-observer-driven model, eliminating configuration for retry intervals and retry limits. The Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Gates Passed
6 Quality Gates Passed
See analysis details in CodeScene
Quality Gate Profile: Pay Down Tech Debt
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a47f22dac3
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (node.nodeType === 1 && node.matches('h1[data-entity-kind="product"]')) { | ||
| if (node.nodeType !== Node.ELEMENT_NODE) return; | ||
|
|
||
| if (node.matches(selector)) { |
There was a problem hiding this comment.
Match dynamic product headers before extra attrs are added
The new observer path now requires node.matches(selector) where selector includes both data-anchor-name and .human_name-view, but the observer is only configured for childList mutations. If Humble inserts a product <h1 data-entity-kind="product"> first and applies those extra attributes/classes afterward (attribute mutation, no new node), this code never calls processElements, so the Steam link is not attached on dynamically rendered pages. The previous implementation handled this case by matching any h1[data-entity-kind="product"] at insertion time.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🧹 Nitpick comments (2)
addSteamLink.user.js (2)
51-57: 💤 Low valueConsider adding early continue for minor efficiency gain.
When a node matches the selector (line 53), the subsequent
querySelectorAll(line 57) will still execute. Sinceh1elements cannot validly contain otherh1elements, this call will always return an empty NodeList, making it redundant. While harmless, you could add areturnafter line 54 to skip the unnecessary query.♻️ Optional optimization
if (node.nodeType !== Node.ELEMENT_NODE) return; if (node.matches(selector)) { processElements([node]); + return; } processElements(node.querySelectorAll(selector));
40-43: ⚡ Quick winAdd
noopenerto thewindow.opencall for security.Opening a new window without
noopenerallows the opened page to accesswindow.opener, which could be a security risk. Whilestore.steampowered.comis trustworthy, addingnoopeneris a defense-in-depth best practice.🔒 Proposed fix to add noopener
element.addEventListener('click', function() { const searchTerm = encodeURIComponent(element.textContent.trim()); - window.open(`https://store.steampowered.com/search/?term=${searchTerm}`, '_blank'); + window.open(`https://store.steampowered.com/search/?term=${searchTerm}`, '_blank', 'noopener,noreferrer'); });
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 78280317-a1ca-4b8e-8b3b-ac4307212e28
📒 Files selected for processing (2)
README.mdaddSteamLink.user.js
Summary\n- Fix userscript update/download URLs to point to the existing addSteamLink.user.js file\n- Start the MutationObserver after the initial scan so dynamically loaded Humble Bundle pages are still handled\n- Process nested product title nodes when Humble inserts a container element\n- Add a direct install link to the README\n\n## Verification\n- node --check addSteamLink.user.js\n- git diff --check
Summary by CodeRabbit
Release Notes
Documentation
Enhancements