@@ -38,7 +38,6 @@ function exists(selector: string): boolean {
3838 * ```
3939 */
4040async function waitFor ( detection : ( ) => boolean ) : Promise < boolean > {
41- // eslint-disable-next-line no-await-in-loop -- We need to wait on each frame
4241 while ( ! detection ( ) && document . readyState !== 'complete' ) {
4342 // eslint-disable-next-line no-await-in-loop
4443 await new Promise ( resolve => {
@@ -183,19 +182,28 @@ TEST: addTests('isGist', [
183182 'https://gist.my-little-hub.com/in-fragrante' ,
184183] ) ;
185184
186- export const isGlobalIssueOrPRList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => [ ' issues' , 'pulls' ] . includes ( url . pathname . split ( '/' , 2 ) [ 1 ] ! ) ;
187- TEST: addTests ( 'isGlobalIssueOrPRList ' , [
185+ export const isGlobalIssueList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ i s s u e s ( $ | \/ ) / . test ( getCleanPathname ( url ) ) ;
186+ TEST: addTests ( 'isGlobalIssueList ' , [
188187 'https://github.com/issues' ,
189- 'https://github.com/issues?q=is%3Apr+is%3Aopen' ,
190188 'https://github.com/issues/assigned' ,
191189 'https://github.com/issues/mentioned' ,
190+ 'https://github.com/issues?q=is%3Apr+is%3Aopen' ,
191+ 'https://github.com//issues/' ,
192+ ] ) ;
193+
194+ export const isGlobalPRList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l s ( $ | \/ ) / . test ( getCleanPathname ( url ) ) ;
195+ TEST: addTests ( 'isGlobalPRList' , [
192196 'https://github.com/pulls' ,
193- 'https://github.com/pulls?q=issues' ,
194197 'https://github.com/pulls/assigned' ,
195198 'https://github.com/pulls/mentioned' ,
196199 'https://github.com/pulls/review-requested' ,
200+ 'https://github.com/pulls?q=issues' ,
201+ 'https://github.com//pulls/' ,
197202] ) ;
198203
204+ export const isGlobalIssueOrPRList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => isGlobalPRList ( url ) || isGlobalIssueList ( url ) ;
205+ TEST: addTests ( 'isGlobalIssueOrPRList' , combinedTestOnly ) ;
206+
199207export const isGlobalSearchResults = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => url . pathname === '/search' && new URLSearchParams ( url . search ) . get ( 'q' ) !== null ;
200208TEST: addTests ( 'isGlobalSearchResults' , [
201209 'https://github.com/search?q=refined-github&ref=opensearch' ,
@@ -206,10 +214,10 @@ TEST: addTests('isIssue', [
206214 'https://github.com/sindresorhus/refined-github/issues/146' ,
207215] ) ;
208216
209- export const isIssueOrPRList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean =>
210- isGlobalIssueOrPRList ( url )
211- || isRepoIssueOrPRList ( url )
212- || isMilestone ( url ) ;
217+ export const isIssueList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => isRepoIssueList ( url ) || isGlobalIssueList ( url ) || isMilestone ( url ) ;
218+ TEST: addTests ( 'isIssueList' , combinedTestOnly ) ;
219+
220+ export const isIssueOrPRList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => isIssueList ( url ) || isPRList ( url ) ;
213221TEST: addTests ( 'isIssueOrPRList' , combinedTestOnly ) ;
214222
215223export const isConversation = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => isIssue ( url ) || isPRConversation ( url ) ;
@@ -318,15 +326,8 @@ TEST: addTests('isPRConflicts', [
318326] ) ;
319327
320328/** Any `isIssueOrPRList` can display both issues and PRs, prefer that detection. `isPRList` only exists because this page has PR-specific filters like the "Reviews" dropdown */
321- export const isPRList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => url . pathname === '/pulls' || getRepo ( url ) ?. path === 'pulls' ;
322- TEST: addTests ( 'isPRList' , [
323- 'https://github.com/pulls' ,
324- 'https://github.com/pulls?q=issues' ,
325- 'https://github.com/sindresorhus/refined-github/pulls' ,
326- 'https://github.com/sindresorhus/refined-github/pulls/' ,
327- 'https://github.com/sindresorhus/refined-github/pulls?q=is%3Aopen+is%3Apr' ,
328- 'https://github.com/sindresorhus/refined-github/pulls?q=is%3Apr+is%3Aclosed' ,
329- ] ) ;
329+ export const isPRList = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => isRepoPRList ( url ) || isGlobalPRList ( url ) ;
330+ TEST: addTests ( 'isPRList' , combinedTestOnly ) ;
330331
331332export const isPRCommit = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => / ^ p u l l \/ \d + \/ ( c o m m i t s | c h a n g e s ) \/ [ \d a - f ] { 7 , 40 } $ / . test ( getRepo ( url ) ?. path ) ;
332333TEST: addTests ( 'isPRCommit' , [
@@ -455,11 +456,46 @@ export const isRepo = (url: URL | HTMLAnchorElement | Location = location): bool
455456} ;
456457
457458TEST: addTests ( 'isRepo' , [
458- // Some of these are here simply as "gotchas" to other detections
459- 'https://github.com/sindresorhus/refined-github/blame/master/package.json' ,
460- 'https://github.com/sindresorhus/refined-github/issues/146' ,
461- 'https://github.com/sindresorhus/notifications/' ,
462- 'https://github.com/sindresorhus/refined-github/pull/148' ,
459+ 'isActionRun' , // Includes isActionJobRun URLs
460+ 'isBranches' ,
461+ 'isCompare' , // Includes isQuickPR URLs
462+ 'isDeletingFile' ,
463+ 'isEditingFile' ,
464+ 'isEditingRelease' ,
465+ 'isFileFinder' ,
466+ 'isForkingRepo' ,
467+ 'isIssue' ,
468+ 'isLabelList' ,
469+ 'isMilestone' ,
470+ 'isMilestoneList' ,
471+ 'isNewAction' ,
472+ 'isNewFile' ,
473+ 'isNewIssue' ,
474+ 'isNewRelease' ,
475+ 'isPR' , // Includes isPRConversation, isPRFiles (→isPRCommit), isPRCommitList
476+ 'isPRConflicts' ,
477+ 'isProjects' ,
478+ 'isReleases' ,
479+ 'isRepoPRList' ,
480+ 'isRepoCommitList' ,
481+ 'isRepoForksList' ,
482+ 'isRepoGitObject' , // Includes isRepoTree (→isRepoRoot→isRepoHome), isSingleFile (→isRenderedTextFile), isBlame
483+ 'isRepoIssueList' ,
484+ 'isRepoNetworkGraph' ,
485+ 'isRepoSearch' ,
486+ 'isRepoSettings' , // Includes isRepoMainSettings
487+ 'isRepoTaxonomyIssueOrPRList' ,
488+ 'isRepoWiki' , // Includes isNewWikiPage, isEditingWikiPage, isCompareWikiPage
489+ 'isRepositoryActions' ,
490+ 'isSingleCommit' ,
491+ 'isSingleReleaseOrTag' ,
492+ 'isTags' ,
493+ // Repo URLs from detections that also cover non-repo pages
494+ 'https://github.com/sindresorhus/refined-github/projects/3' , // From isProject
495+ 'https://github.com/tophf/mpiv/discussions/50' , // From isDiscussion
496+ 'https://github.com/withastro/roadmap/discussions/new?category=proposal' , // From isNewDiscussion
497+ 'https://github.com/tophf/mpiv/discussions' , // From isDiscussionList
498+ // These URLs are repos but don't match any specific detection
463499 'https://github.com/sindresorhus/refined-github/milestones/new' , // Gotcha for isRepoTaxonomyIssueOrPRList
464500 'https://github.com/sindresorhus/refined-github/milestones/1/edit' , // Gotcha for isRepoTaxonomyIssueOrPRList
465501 'https://github.com/sindresorhus/refined-github/issues/new/choose' , // Gotcha for isRepoIssueList
@@ -538,6 +574,8 @@ TEST: addTests('isRepoHome', [
538574 'https://github.com/sindresorhus/search' ,
539575 'https://github.com/sindresorhus/branches' ,
540576 'https://github.com/sindresorhus/refined-github?files=1' ,
577+ 'https://github.com/pullsuser/my-library' ,
578+ 'https://github.com/issuesuser/my-library' ,
541579] ) ;
542580
543581export type RepoExplorerInfo = {
@@ -791,6 +829,8 @@ TEST: addTests('isProfile', [
791829 'https://github.com/sindresorhus?tab=followers' ,
792830 'https://github.com/fregante?tab=following' ,
793831 'https://github.com/sindresorhus?tab=following' ,
832+ 'https://github.com/pullsuser' , // Gotcha for isGlobalPRList
833+ 'https://github.com/issuesuser' , // Gotcha for isGlobalIssueList
794834] ) ;
795835
796836export const isGistProfile = ( url : URL | HTMLAnchorElement | Location = location ) : boolean => doesLookLikeAProfile ( getCleanGistPathname ( url ) ) ;
0 commit comments