diff options
author | 2022-07-05 23:26:44 +0700 | |
---|---|---|
committer | 2022-07-05 23:26:44 +0700 | |
commit | 88e2668dbc0fbdd7c78af2747c1f022309289eea (patch) | |
tree | 92e8dbb29efd0883a57c73bc8e0427cb93cf1654 /source/features/one-click-pr-or-gist.tsx | |
parent | f6cd9d243fdc3e5facb56085274c7cf92c4053e6 (diff) | |
download | refined-github-88e2668dbc0fbdd7c78af2747c1f022309289eea.tar.gz refined-github-88e2668dbc0fbdd7c78af2747c1f022309289eea.tar.zst refined-github-88e2668dbc0fbdd7c78af2747c1f022309289eea.zip |
Add `has()` selector helper (#5518)
Diffstat (limited to 'source/features/one-click-pr-or-gist.tsx')
-rw-r--r-- | source/features/one-click-pr-or-gist.tsx | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/source/features/one-click-pr-or-gist.tsx b/source/features/one-click-pr-or-gist.tsx index 9762a064..6d7cfd0a 100644 --- a/source/features/one-click-pr-or-gist.tsx +++ b/source/features/one-click-pr-or-gist.tsx @@ -4,17 +4,16 @@ import select from 'select-dom'; import * as pageDetect from 'github-url-detection'; import features from '.'; +import selectHas from '../helpers/select-has'; function init(): void | false { - const draftPROption = select('.new-pr-form [name="draft"], #new_gist [name="gist[public]"]'); - if (!draftPROption) { + const initialGroupedButtons = selectHas('.BtnGroup:has([name="draft"], [name="gist[public]"])'); + if (!initialGroupedButtons) { // 1. Free accounts can't open Draft PRs in private repos, so this element is missing // 2. PRs can't be created from some comparison pages: Either base is a tag, not a branch; or there already exists a PR. return false; } - const initialGroupedButtons = draftPROption.closest('.BtnGroup')!; - for (const dropdownItem of select.all('.select-menu-item', initialGroupedButtons)) { let title = select('.select-menu-item-heading', dropdownItem)!.textContent!.trim(); const description = select('.description', dropdownItem)!.textContent!.trim(); |