@@ -31,9 +31,20 @@ export async function createGitIngestButton(): Promise<HTMLLIElement> {
3131 const link = document . createElement ( 'a' ) ;
3232 link . className = 'btn-sm btn' ;
3333
34- // Get custom base URL from storage, default to gitingest.com if not set
35- const baseUrl = await storage . getItem < string > ( 'sync:baseUrl' ) || 'gitingest.com' ;
36- link . href = window . location . href . replace ( 'github.com' , baseUrl ) ;
34+ // Get custom base URL and window preference from storage
35+ const [ baseUrl , openInNewWindow ] = await Promise . all ( [
36+ storage . getItem < string > ( 'sync:baseUrl' ) ,
37+ storage . getItem < boolean > ( 'sync:openInNewWindow' )
38+ ] ) ;
39+
40+ // Set default base URL if not set
41+ link . href = window . location . href . replace ( 'github.com' , baseUrl || 'gitingest.com' ) ;
42+
43+ // Set target based on preference
44+ if ( openInNewWindow ) {
45+ link . target = '_blank' ;
46+ link . rel = 'noopener noreferrer' ;
47+ }
3748
3849 // Create spans for different screen sizes
3950 const linkContent = `
@@ -45,7 +56,6 @@ export async function createGitIngestButton(): Promise<HTMLLIElement> {
4556
4657 // Add button to container
4758 li . appendChild ( link ) ;
48-
4959 li . id = 'git-ingest-button' ;
5060
5161 return li ;
@@ -69,7 +79,12 @@ storage.watch('sync:baseUrl', () => {
6979 const link = button . querySelector ( 'a' ) ;
7080 if ( link ) {
7181 createGitIngestButton ( ) . then ( newButton => {
72- link . href = newButton . querySelector ( 'a' ) ?. href || link . href ;
82+ const newLink = newButton . querySelector ( 'a' ) ;
83+ if ( newLink ) {
84+ link . href = newLink . href ;
85+ link . target = newLink . target ;
86+ link . rel = newLink . rel ;
87+ }
7388 } ) ;
7489 }
7590 }
0 commit comments