Skip to content

Commit 0bfa779

Browse files
committed
feat: storage baseurl now worked
1 parent 5577478 commit 0bfa779

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

entrypoints/content/git-ingest-button.ts

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
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+
});

entrypoints/content/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ export default defineContentScript({
1313

1414
if (isRepoPage()) {
1515
if (!existingButton) {
16-
const button = createGitIngestButton();
17-
appendGitIngestButton(button);
16+
// Handle async operation without changing function signature
17+
createGitIngestButton()
18+
.then(button => appendGitIngestButton(button))
19+
.catch(console.error);
1820
}
1921
} else {
2022
existingButton?.remove();

entrypoints/popup/App.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ function App() {
6868
<div className="mt-6 text-sm text-green-600 font-medium text-center relative z-20">
6969
Settings saved!
7070
<br />
71-
<span className="ml-2 font-normal text-gray-600 text-xs">
71+
{/* <span className="ml-2 font-normal text-gray-600 text-xs">
7272
You may need to refresh the page.
73-
</span>
73+
</span> */}
7474
</div>
7575
)}
7676
</div>

0 commit comments

Comments
 (0)