Repository navigation
Live Branches: Support GitHub's new pull request page layout - #54851
Merged
Merged
Conversation
GitHub now serves some users a React-based PR page that has no `.pull-discussion-timeline` wrapper, so the script found no PR body and rendered nothing. Labels moved as well, into a sidebar section of Primer tokens without the `IssueLabel` class or `data-name` attribute, which would have left every plugin unchecked by default. Match the PR body and labels in both layouts. The new selectors key on `aria-label` rather than the layout's hashed class names, which are unlikely to survive GitHub's next build. Branch and state already come from the embedded JSON, which both layouts provide.
Contributor
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
anomiex
reviewed
Nov 12, 2026
Comment on lines
+140
to
+145
| const labels = new Set( | ||
| $.map( $( '.js-issue-labels a.IssueLabel' ), e => $( e ).data( 'name' ) ) | ||
| ); | ||
| $( 'section[aria-label="Labels"] a[href*="label%3A"]' ).each( ( i, e ) => { | ||
| labels.add( e.textContent.trim() ); | ||
| } ); |
Contributor
There was a problem hiding this comment.
If we're going to trust textContent, you could probably have simplified this a bit
Suggested change
| const labels = new Set( | |
| $.map( $( '.js-issue-labels a.IssueLabel' ), e => $( e ).data( 'name' ) ) | |
| ); | |
| $( 'section[aria-label="Labels"] a[href*="label%3A"]' ).each( ( i, e ) => { | |
| labels.add( e.textContent.trim() ); | |
| } ); | |
| const labels = new Set( | |
| $.map( $( '.js-issue-labels a.IssueLabel, section[aria-label="Labels"] a[href*="label%3A"]' ), e => e.textContent.trim() ) | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
GitHub now shows some people a new pull request page, built in React. On that page the Jetpack Live Branches userscript shows nothing at all: it looks for the PR description inside
.pull-discussion-timeline, and that wrapper no longer exists. The labels moved too, into a sidebar list without theIssueLabelclass ordata-nameattribute, so even with the description found, no plugin would have been ticked by default.This PR updates the script so it finds both, whichever layout you get:
section[aria-label="Description"] .markdown-body.getPRLabels()reads label names from the classic sidebar and from the newsection[aria-label="Labels"], so plugins are still ticked based on the PR's[Plugin] …labels.I bumped the version to 1.39 so Tampermonkey picks up the update.
The new selectors rely on
aria-labels rather than class names, since the new layout's classes are hashed (body__fphukB,container__qcj0r_) and will likely change with GitHub's next build. The branch name and PR state already came from the page's embedded JSON (#46958), which both layouts still provide, so that part didn't need to change.Related product discussion/links
Does this pull request change what data or activity we track or use?
No.
Testing instructions
You'll need the userscript installed in Tampermonkey, or a similar extension.
[Plugin] …labels should be ticked (Jetpack and Jetpack Backup on Backup: remove the four REST routes only the legacy dashboard called #53859), plugins with a build but no label available but unticked (Jetpack Protect), and the rest greyed out.trunkinstead.I ran steps 2 and 3 on the new layout. Tampermonkey wasn't installed in that browser, so I injected the script into the page by hand and fed it a saved
query-branch.phpresponse. I haven't run step 4 on the classic layout yet; I'll do that with the real Tampermonkey install before asking for review.