This app runs inside the BotSurf browser. Don't have it yet? Get the app or extension now!

GitHub PR Diff Line Counter

Developer Tools · All
0 installs · Verified BotGentz app
Launch App
Opens in BotSurf — try it free, no account needed.
CategoryDeveloper Tools
PlatformAll
Pricing Free
Installs0
Download BotSurf to use — free
No account needed for free apps. Once BotSurf is open, find this app in Apps from the + menu.

About this app

WHAT IT DOES

This script adds a detailed line count summary to GitHub pull request diff pages. When you view a PR's diff, the script scans all changed files, counts lines with '+' (additions) and '-' (deletions) in each file, and displays a summary badge at the top of the page. The summary shows total additions, total deletions, net change, and the number of files changed. For PRs with multiple files, a per-file breakdown shows each file's additions, deletions, and net change, making it easy to see which files have the most changes at a glance. A "Copy summary" button lets you copy the entire line count summary to your clipboard for sharing in PR comments, team discussions, or documentation.

WHERE IT RUNS

The script runs on all GitHub pull request diff pages (github.com/*/*/pull/* and */*/pull/*/files). It works on both the PR overview page and the files-changed tab. It handles both desktop and mobile views, and updates dynamically as the user scrolls and loads more diff content.

HOW TO USE

After installation, the settings panel appears on the left side of the screen with the gear emoji (⚙️). Open the panel to configure the script:

- The "Enable line counting" toggle enables or disables the script.

- Toggle "Show file breakdown" to show or hide the per-file breakdown in the summary.

- Click "Refresh counts" to manually re-scan the page if new diffs load.

- Click "Copy summary" to copy the line count summary to your clipboard.

The summary appears at the top of the PR page automatically. It updates as you scroll and load more diff content.

TECHNICAL SECTION — REAL MECHANISM

The script detects PR diff pages by checking the URL for /pull/ and /files. It finds file containers using selectors like .file, .js-file, .js-diff-file, and .file-header. For each file, the script extracts the filename from .file-header .file-info or .js-file-name. It then counts lines by scanning the diff content text and counting lines that start with '+' (additions) and '-' (deletions), excluding diff header lines like "+++" and "---". As a fallback, it also counts lines by checking for .blob-code-addition and .blob-code-deletion CSS classes on table rows. The summary badge is created as a fixed-position or inserted div with a dark glassmorphism style, positioned at the top of the page. The per-file breakdown is rendered as a scrollable list. The script uses a WeakSet to track processed files and avoid duplicate counting. A MutationObserver watches for DOM changes and triggers re-processing when new diff files are loaded. The copy function uses GM_setClipboard to copy a formatted summary including all file counts.

THE PANEL

The settings panel is built with BotGentz's BGPanel component. It is draggable via its header, allowing you to reposition it anywhere on the screen. The panel snaps to the left edge by default but can be moved freely. Click the gear emoji to collapse the panel into a small bubble, and click the bubble to expand it again. The panel remembers its position per page session. Press the Escape key to quickly close or minimize the panel. The panel includes a status flash bar that provides visual feedback when settings are changed or actions are performed. All settings save automatically via GM_setValue.

PLEASE NOTE

This script requires the free BotGentz browser extension to run. It does not function as a standalone Chrome extension and does not use chrome.* APIs. GitHub frequently updates its diff view structure, which may affect file detection or line counting. If the script stops working, please check for updates. The line counting counts every line that starts with '+' or '-' in the diff view—this matches GitHub's own line count display. The script does not count lines in collapsed or hidden diff sections. The script stores only your preferences via GM_setValue. No data is sent externally—all data is stored locally in your browser. The script never reads or writes password fields, hidden inputs, or file inputs. All DOM operations use safe methods (style properties, textContent, appendChild) and never use innerHTML.

Similar Apps

Log in to BotGentz

Suggest an App

Tell us what you'd find useful — if we build it, we'll email you the moment it's ready.