Skip to content

Fix userscript install URL and dynamic loading#1

Open
mookechee wants to merge 1 commit into
mainfrom
fix-userscript-install-and-observer
Open

Fix userscript install URL and dynamic loading#1
mookechee wants to merge 1 commit into
mainfrom
fix-userscript-install-and-observer

Conversation

@mookechee

@mookechee mookechee commented May 25, 2026

Copy link
Copy Markdown
Owner

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

    • Added installation guide with step-by-step instructions for installing the userscript using Tampermonkey or Violentmonkey, including a direct download link and userscript manager prerequisites.
  • Enhancements

    • Improved detection and processing of dynamically added content on pages for more reliable functionality.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This 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 initialize() function now processes matching elements directly and starts monitoring for DOM changes immediately. The mutation observer logic is simplified to skip non-element nodes and handle both direct node matches and descendant queries. Installation instructions have been added to the README with a direct link to the userscript and a prerequisite note about installing a compatible userscript manager.

Poem

🐰 A curious coder hops through the DOM,
Trading retries for watchers so keen,
Mutation observers now catch every bloom,
While README guides users serene!
Leap, observe, and let change be seen!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly addresses the main changes: fixing the userscript install URL (README addition) and improving dynamic loading with mutation observer (addSteamLink.user.js refactoring).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codescene-delta-analysis codescene-delta-analysis Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread addSteamLink.user.js
if (node.nodeType === 1 && node.matches('h1[data-entity-kind="product"]')) {
if (node.nodeType !== Node.ELEMENT_NODE) return;

if (node.matches(selector)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (2)
addSteamLink.user.js (2)

51-57: 💤 Low value

Consider adding early continue for minor efficiency gain.

When a node matches the selector (line 53), the subsequent querySelectorAll (line 57) will still execute. Since h1 elements cannot validly contain other h1 elements, this call will always return an empty NodeList, making it redundant. While harmless, you could add a return after 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 win

Add noopener to the window.open call for security.

Opening a new window without noopener allows the opened page to access window.opener, which could be a security risk. While store.steampowered.com is trustworthy, adding noopener is 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

📥 Commits

Reviewing files that changed from the base of the PR and between 4cbfb51 and a47f22d.

📒 Files selected for processing (2)
  • README.md
  • addSteamLink.user.js

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