11import OverType , { type OverTypeInstance } from 'overtype'
2- import type { CommentEnhancer , CommentSpot } from '../../enhancer'
2+ import type { CommentEnhancer , CommentSpot , StrippedLocation } from '../../enhancer'
33import { logger } from '../../logger'
44import { modifyDOM } from '../modifyDOM'
55import { commonGithubOptions } from './ghOptions'
@@ -16,22 +16,25 @@ export class GitHubPRNewCommentEnhancer implements CommentEnhancer<GitHubPRNewCo
1616 return [ 'GH_PR_NEW_COMMENT' ]
1717 }
1818
19- tryToEnhance ( textarea : HTMLTextAreaElement ) : GitHubPRNewCommentSpot | null {
19+ tryToEnhance (
20+ textarea : HTMLTextAreaElement ,
21+ location : StrippedLocation ,
22+ ) : GitHubPRNewCommentSpot | null {
2023 if ( textarea . id === 'feedback' ) {
2124 return null
2225 }
23- if ( document . querySelector ( 'meta[name="hostname"]' ) ?. getAttribute ( 'content' ) !== 'github.com' ) {
26+ if ( location . domain !== 'github.com' ) {
2427 return null
2528 }
2629
2730 // /owner/repo/compare/feature/more-enhancers?expand=1
2831 // or /owner/repo/compare/feat/issue-static-and-dynamic...feature/more-enhancers?expand=1
29- logger . info ( `${ this . constructor . name } examing url` , window . location . pathname )
32+ logger . info ( `${ this . constructor . name } examing url` , location . pathname )
3033
31- const match = window . location . pathname . match (
34+ const match = location . pathname . match (
3235 / ^ \/ ( [ ^ / ] + ) \/ ( [ ^ / ] + ) \/ c o m p a r e \/ (?: ( [ ^ . ? ] + ) \. \. \. ) ? ( [ ^ ? ] + ) / ,
3336 )
34- logger . info ( `${ this . constructor . name } found match` , window . location . pathname , match )
37+ logger . info ( `${ this . constructor . name } found match` , location . pathname , match )
3538
3639 if ( ! match ) return null
3740 const [ , owner , repo , baseBranch , compareBranch ] = match
@@ -40,7 +43,7 @@ export class GitHubPRNewCommentEnhancer implements CommentEnhancer<GitHubPRNewCo
4043 : `${ owner } /${ repo } /${ compareBranch } `
4144 const unique_key = `github.com:${ slug } `
4245 return {
43- domain : 'github.com' ,
46+ domain : location . domain ,
4447 slug,
4548 type : 'GH_PR_NEW_COMMENT' ,
4649 unique_key,
0 commit comments