Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ jobs:
- name: Install browser extension dependencies
working-directory: browser
run: npm ci
- name: Prepare WXT
working-directory: browser
run: npm run prepare
- name: Lint browser extension
working-directory: browser
run: npm run lint
Expand Down Expand Up @@ -200,6 +203,9 @@ jobs:
- name: Install browser extension dependencies
working-directory: browser
run: npm ci
- name: Prepare WXT
working-directory: browser
run: npm run prepare
- name: Test browser extension
working-directory: browser
run: npm run test
Expand Down
2 changes: 2 additions & 0 deletions browser/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ yarn-error.log*
# Build output
dist/
packages/
.output/
.wxt/

# Environment variables
.env
Expand Down
67 changes: 0 additions & 67 deletions browser/app/manifest.json

This file was deleted.

54 changes: 0 additions & 54 deletions browser/app/scripts/background.ts

This file was deleted.

56 changes: 56 additions & 0 deletions browser/entrypoints/background.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
export default defineBackground(() => {
const injectContentToTab = async (tab: chrome.tabs.Tab): Promise<void> => {
// Skip if URL is undefined
if (!tab.url) {
return;
}

// Skip if tab is discarded
if (tab.discarded) {
return;
}

// Skip if tab ID is undefined
if (tab.id === undefined) {
return;
}

// Skip if not a GitHub URL
if (!tab.url.startsWith('https://github.com/')) {
return;
}
Comment thread
yamadashy marked this conversation as resolved.

try {
const manifest = chrome.runtime.getManifest();

// Inject CSS
if (manifest.content_scripts?.[0]?.css) {
await chrome.scripting.insertCSS({
target: { tabId: tab.id },
files: manifest.content_scripts[0].css,
});
}

// Inject JavaScript
if (manifest.content_scripts?.[0]?.js) {
await chrome.scripting.executeScript({
target: { tabId: tab.id },
files: manifest.content_scripts[0].js,
});
}
} catch (error) {
console.error('Error injecting content script:', error);
}
Comment thread
yamadashy marked this conversation as resolved.
};

// Update extension content for tabs
chrome.tabs.query({}, async (tabs: chrome.tabs.Tab[]) => {
for (const tab of tabs) {
try {
await injectContentToTab(tab);
} catch (e) {
console.error(e);
}
}
});
Comment thread
yamadashy marked this conversation as resolved.
Comment thread
yamadashy marked this conversation as resolved.
Comment on lines +47 to +55
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current code iterates through tabs and injects scripts sequentially using await in a for...of loop. This can be slow if the user has many tabs open. To improve performance on extension startup, you can process tabs in parallel. Since injectContentToTab handles its own errors, you can call it for each tab without waiting for it to complete.

  chrome.tabs.query({}, (tabs: chrome.tabs.Tab[]) => {
    // Process tabs in parallel for faster startup.
    tabs.forEach((tab) => injectContentToTab(tab));
  });

});
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import './styles.css';

interface RepositoryInfo {
owner: string;
repo: string;
Expand Down Expand Up @@ -146,9 +148,16 @@ function initRepomixIntegration(): void {
}
}

// Initialize when DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => initRepomixIntegration());
} else {
initRepomixIntegration();
}
export default defineContentScript({
matches: ['https://github.com/*'],
runAt: 'document_start',
allFrames: true,
main() {
// Initialize when DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', () => initRepomixIntegration());
} else {
initRepomixIntegration();
}
},
});
File renamed without changes.
Loading
Loading