11// Create and return the GitIngest button element
2- export function createGitIngestButton ( ) : HTMLLIElement {
2+ import { storage } from 'wxt/storage' ;
3+
4+ export async function createGitIngestButton ( ) : Promise < HTMLLIElement > {
35 // Add custom styles
46 const style = document . createElement ( 'style' ) ;
57 style . textContent = `
@@ -28,7 +30,10 @@ export function createGitIngestButton(): HTMLLIElement {
2830 // Create link with GitHub's button style
2931 const link = document . createElement ( 'a' ) ;
3032 link . className = 'btn-sm btn' ;
31- link . href = window . location . href . replace ( 'github.com' , 'gitingest.com' ) ;
33+
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 ) ;
3237
3338 // Create spans for different screen sizes
3439 const linkContent = `
@@ -55,4 +60,17 @@ export function appendGitIngestButton(button: HTMLElement) {
5560 actionsList . insertBefore ( button , actionsList . firstChild ) ;
5661 }
5762 }
58- }
63+ }
64+
65+ // Add storage change listener to update button URL when settings change
66+ storage . watch ( 'sync:baseUrl' , ( ) => {
67+ const button = document . getElementById ( 'git-ingest-button' ) ;
68+ if ( button ) {
69+ const link = button . querySelector ( 'a' ) ;
70+ if ( link ) {
71+ createGitIngestButton ( ) . then ( newButton => {
72+ link . href = newButton . querySelector ( 'a' ) ?. href || link . href ;
73+ } ) ;
74+ }
75+ }
76+ } ) ;
0 commit comments