diff options
author | 2023-11-01 12:24:19 +0800 | |
---|---|---|
committer | 2023-11-01 04:24:19 +0000 | |
commit | ae6ca57b45b4e4ad201793b8dc7f3535c43de976 (patch) | |
tree | 679608ff74b842731d0a1ce8591d2c17dd727010 /source/features/use-first-commit-message-for-new-prs.tsx | |
parent | 4a9e021202ceb76962d08d70ecab2ec9becab8d9 (diff) | |
download | refined-github-ae6ca57b45b4e4ad201793b8dc7f3535c43de976.tar.gz refined-github-ae6ca57b45b4e4ad201793b8dc7f3535c43de976.tar.zst refined-github-ae6ca57b45b4e4ad201793b8dc7f3535c43de976.zip |
Meta: Use new `select-dom` API (#6992)
Diffstat (limited to 'source/features/use-first-commit-message-for-new-prs.tsx')
-rw-r--r-- | source/features/use-first-commit-message-for-new-prs.tsx | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/source/features/use-first-commit-message-for-new-prs.tsx b/source/features/use-first-commit-message-for-new-prs.tsx index 7f263979..6dff0a3f 100644 --- a/source/features/use-first-commit-message-for-new-prs.tsx +++ b/source/features/use-first-commit-message-for-new-prs.tsx @@ -1,4 +1,4 @@ -import select from 'select-dom'; +import {$, elementExists} from 'select-dom'; import elementReady from 'element-ready'; import * as pageDetect from 'github-url-detection'; import * as textFieldEdit from 'text-field-edit'; @@ -24,8 +24,8 @@ function interpretNode(node: ChildNode): string | void { } function getFirstCommit(): {title: string; body: string | undefined} { - const titleParts = select('.js-commits-list-item:first-child p')!.childNodes; - const body = select('.js-commits-list-item:first-child .Details-content--hidden pre') + const titleParts = $('.js-commits-list-item:first-child p')!.childNodes; + const body = $('.js-commits-list-item:first-child .Details-content--hidden pre') ?.textContent.trim() ?? undefined; const title = [...titleParts] @@ -40,21 +40,21 @@ async function init(): Promise<void | false> { const requestedContent = new URL(location.href).searchParams; const commitCountIcon = await elementReady('div.Box.mb-3 .octicon-git-commit'); const commitCount = commitCountIcon?.nextElementSibling; - if (!commitCount || looseParseInt(commitCount) < 2 || !select.exists('#new_pull_request')) { + if (!commitCount || looseParseInt(commitCount) < 2 || !elementExists('#new_pull_request')) { return false; } const firstCommit = getFirstCommit(); if (!requestedContent.has('pull_request[title]')) { textFieldEdit.set( - select('.discussion-topic-header input')!, + $('.discussion-topic-header input')!, firstCommit.title, ); } if (firstCommit.body && !requestedContent.has('pull_request[body]')) { textFieldEdit.insert( - select('#new_pull_request textarea[aria-label="Comment body"]')!, + $('#new_pull_request textarea[aria-label="Comment body"]')!, firstCommit.body, ); } |