Skip to content

fix: GitHub LOC injection and API compatibility - #82

Closed
dongguacute wants to merge 5 commits into
DervexDev:mainfrom
dongguacute:main
Closed

dongguacute wants to merge 5 commits into
DervexDev:mainfrom
dongguacute:main

Conversation

@dongguacute

@dongguacute dongguacute commented Aug 18, 2026

Copy link
Copy Markdown
  • Fix GitHub About section injection for the latest GitHub DOM.
  • Switch LOC requests to the public ghloc.dev API.
  • Make Ghloc-Authorization optional for self-hosted deployments.
  • Fix 404 errors by detecting the repository’s actual default branch instead of assuming main.

- Updated the `locateRoot` function to use a MutationObserver for dynamic DOM changes, enhancing the reliability of root element detection.
- Modified the `loadLoc` function to improve type safety and URL construction for fetching LOC data, including support for custom branch names with slashes.
- Updated the link in the `Stat` component to point to the new domain for the application.
- Updated the URL construction in the `fetchLoc` function to handle optional branch paths more cleanly.
- Modified the `Stat` component's link to conditionally include the branch parameter based on its presence.
- Improved branch detection logic in the `getTarget` function to utilize more reliable DOM selectors.
- Updated the `fetchLoc` function to accept an `isPublic` parameter, allowing for conditional API URL selection based on repository visibility.
- Introduced a new `isPublicRepository` function to determine repository visibility more reliably.
- Refactored the `locateRoot` function to utilize the new visibility detection logic, improving the overall robustness of the LOC fetching process.
@dongguacute
dongguacute marked this pull request as draft August 18, 2026 17:38
…nd file filtering

- Introduced new interfaces for GitHub API responses to improve type safety.
- Refactored the `fetchLocalLoc` and `fetchPublicLoc` functions to streamline LOC data retrieval and incorporate ignored file filtering.
- Added utility functions for decoding base64 content and counting text lines, enhancing the overall robustness of the LOC fetching process.
- Improved error handling for GitHub API requests to provide clearer feedback on failures.
@dongguacute
dongguacute marked this pull request as ready for review August 18, 2026 17:43
- Removed the redundant `isInjected` function to simplify the injection process.
- Updated the `injectStat` function to check for an existing element before creating a new one, improving efficiency.
- Ensured proper placement of the injected element based on the presence of specific text in the last child of the root element.
@DervexDev

Copy link
Copy Markdown
Owner

Thanks for the contribution — the About-section injection and default-branch detection fixes are useful.

I'm closing this PR because we don't want to switch LOC fetching to the public ghloc.dev API or add in-browser/local counting. This extension relies on a custom ghloc backend that already supports private repos via the user's GitHub token, and dropping that path would break private-repo support.

I've extracted just the injection + default-branch fixes into a separate PR: #84

@DervexDev DervexDev closed this Sep 15, 2026
@DervexDev

Copy link
Copy Markdown
Owner

The close comment above was generated by Grok Bot.

DervexDev added a commit that referenced this pull request Sep 15, 2026
- Improve About section detection using normalize-space XPath for better DOM compatibility
- Add MutationObserver to handle cases where About section loads after initial page paint
- Reuse existing #github-loc element to prevent widget duplication on re-injection
- Improve branch detection by checking tree/blob path and branch selector with fallbacks
- Stop defaulting to 'main' branch - use empty string to let backend resolve default
- Handle empty branch in API URL and Stat link to support default branch resolution
- Encode branch parameter in Stat link for proper URL formatting

Changes extracted from PR #82 by dongguacute, keeping only DOM/branch fixes
while maintaining the existing custom ghloc backend with token support.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
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