Skip to content

Commit 4b29514

Browse files
committed
feat(firefox): start enable firefox support
1 parent c53ec99 commit 4b29514

19 files changed

+1532
-9
lines changed

.env.sample

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
TALENT_PROTOCOL_API_KEY=
2+
SUPABASE_URL=
3+
SUPABASE_KEY=
4+
DUNE_API_KEY=
5+
NEXT_PUBLIC_SUPABASE_URL=
6+
NEXT_PUBLIC_SUPABASE_ANON_KEY=

.github/workflows/build.yaml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Build Extension
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
# Allow manual trigger
9+
workflow_dispatch:
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
strategy:
16+
matrix:
17+
node-version: [18.x]
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Use Node.js ${{ matrix.node-version }}
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ matrix.node-version }}
26+
cache: 'npm'
27+
28+
- name: Install dependencies
29+
run: npm ci
30+
31+
- name: Build Chrome extension
32+
run: npm run build:chrome
33+
env:
34+
NODE_ENV: production
35+
36+
- name: Build Firefox extension
37+
run: npm run build:firefox
38+
env:
39+
NODE_ENV: production
40+
41+
- name: Build Firefox XPI
42+
run: npm run build:firefox-xpi
43+
44+
- name: Package Chrome extension
45+
run: |
46+
cd dist/chrome
47+
zip -r ../../chrome-extension.zip ./*
48+
cd ../..
49+
50+
- name: Upload Chrome artifact
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: chrome-extension
54+
path: chrome-extension.zip
55+
56+
- name: Upload Firefox artifact
57+
uses: actions/upload-artifact@v4
58+
with:
59+
name: firefox-extension
60+
path: web-ext-artifacts/*.xpi
61+
62+
release:
63+
needs: build
64+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
65+
runs-on: ubuntu-latest
66+
permissions:
67+
contents: write
68+
69+
steps:
70+
- name: Download Chrome artifact
71+
uses: actions/download-artifact@v4
72+
with:
73+
name: chrome-extension
74+
75+
- name: Download Firefox artifact
76+
uses: actions/download-artifact@v4
77+
with:
78+
name: firefox-extension
79+
80+
- name: Get version
81+
id: package_version
82+
run: |
83+
echo "VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
84+
85+
- name: Create Release
86+
id: create_release
87+
uses: softprops/action-gh-release@v1
88+
with:
89+
tag_name: v${{ env.VERSION }}
90+
name: Release v${{ env.VERSION }}
91+
draft: false
92+
prerelease: false
93+
files: |
94+
chrome-extension.zip
95+
*.xpi
96+
env:
97+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98+
99+
lint:
100+
runs-on: ubuntu-latest
101+
102+
steps:
103+
- uses: actions/checkout@v4
104+
105+
- name: Use Node.js
106+
uses: actions/setup-node@v4
107+
with:
108+
node-version: '18.x'
109+
cache: 'npm'
110+
111+
- name: Install dependencies
112+
run: npm ci
113+
114+
- name: Install web-ext
115+
run: npm install -g web-ext
116+
117+
- name: Lint Firefox extension
118+
run: |
119+
npm run build:firefox
120+
web-ext lint -s dist/firefox

manifest.chrome.json

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "BuilderScore",
4+
"version": "1.0.1",
5+
"description": "Display Builder Scores from Talent Protocol on X profiles",
6+
"icons": {
7+
"16": "icons/icon-16.png",
8+
"32": "icons/icon-32.png",
9+
"48": "icons/icon-48.png",
10+
"128": "icons/icon-128.png"
11+
},
12+
"content_security_policy": {
13+
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'",
14+
"sandbox": "sandbox allow-scripts allow-forms allow-popups allow-modals"
15+
},
16+
"background": {
17+
"service_worker": "background.js",
18+
"type": "module"
19+
},
20+
"action": {
21+
"default_popup": "popup.html",
22+
"default_icon": {
23+
"16": "icons/icon-16.png",
24+
"32": "icons/icon-32.png",
25+
"48": "icons/icon-48.png",
26+
"128": "icons/icon-128.png"
27+
}
28+
},
29+
"permissions": [
30+
"storage",
31+
"activeTab",
32+
"tabs",
33+
"scripting",
34+
"alarms"
35+
],
36+
"host_permissions": [
37+
"*://*.linkedin.com/*",
38+
"*://*.talentprotocol.com/*",
39+
"*://*.x.com/*",
40+
"*://*.twitter.com/*",
41+
"*://*.github.com/*",
42+
"https://*.warpcast.com/*",
43+
"https://warpcast.com/*",
44+
"*://*.talent.aipop.fun/*"
45+
],
46+
"content_scripts": [
47+
{
48+
"matches": [
49+
"*://*.x.com/*",
50+
"*://*.twitter.com/*",
51+
"*://*.github.com/*",
52+
"*://*.warpcast.com/*",
53+
"https://*.warpcast.com/*",
54+
"https://warpcast.com/*",
55+
"*://*.linkedin.com/*"
56+
],
57+
"js": ["content.js"],
58+
"css": [
59+
"global.css",
60+
"styles.css"
61+
],
62+
"run_at": "document_idle",
63+
"all_frames": false
64+
}
65+
],
66+
"web_accessible_resources": [
67+
{
68+
"resources": [
69+
"icons/*",
70+
"*.js",
71+
"*.css"
72+
],
73+
"matches": [
74+
"*://*.x.com/*",
75+
"*://*.twitter.com/*",
76+
"https://*.warpcast.com/*",
77+
"https://warpcast.com/*",
78+
"*://*.warpcast.com/*",
79+
"*://*.linkedin.com/*"
80+
]
81+
}
82+
]
83+
}

manifest.firefox.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"manifest_version": 3,
3+
"name": "Builder Score Extension",
4+
"version": "1.0.1",
5+
"description": "Extension to display Builder Scores on social platforms",
6+
"permissions": [
7+
"storage",
8+
"webRequest",
9+
"*://*.talent.aipop.fun/*",
10+
"*://*.twitter.com/*",
11+
"*://*.warpcast.com/*",
12+
"*://*.linkedin.com/*"
13+
],
14+
"background": {
15+
"scripts": ["background.js"],
16+
"persistent": false
17+
},
18+
"content_scripts": [
19+
{
20+
"matches": [
21+
"https://*.twitter.com/*",
22+
"https://*.warpcast.com/*",
23+
"https://*.linkedin.com/*"
24+
],
25+
"js": ["content.js"]
26+
}
27+
],
28+
"icons": {
29+
"48": "icons/icon-48.png",
30+
"128": "icons/icon-128.png"
31+
},
32+
"browser_specific_settings": {
33+
"gecko": {
34+
"id": "builder-score@extension.org",
35+
"strict_min_version": "57.0"
36+
}
37+
}
38+
}

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44
"author": "codingsh",
55
"description": "Chrome extension to replace addresses with Farcaster names on DexScreener",
66
"scripts": {
7-
"build": "webpack --config webpack.config.js",
8-
"dev": "webpack --config webpack.config.js --watch"
7+
"build:chrome": "webpack --config webpack.config.js --env browser=chrome",
8+
"build:firefox": "webpack --config webpack.config.js --env browser=firefox",
9+
"build": "npm run build:chrome && npm run build:firefox",
10+
"dev:chrome": "webpack --config webpack.config.js --env browser=chrome --watch",
11+
"dev:firefox": "webpack --config webpack.config.js --env browser=firefox --watch",
12+
"build:firefox-xpi": "web-ext build --source-dir ./dist/firefox --artifacts-dir ./web-ext-artifacts"
913
},
1014
"dependencies": {
1115
"@radix-ui/react-switch": "^1.1.1",
1216
"@supabase/supabase-js": "^2.48.1",
17+
"@types/firefox-webext-browser": "^120.0.4",
1318
"autoprefix": "^1.0.1",
1419
"class-variance-authority": "^0.7.1",
1520
"dotenv": "^16.0.3",
@@ -20,6 +25,7 @@
2025
"tailwind-merge": "^2.5.5",
2126
"tailwindcss-animate": "^1.0.7",
2227
"terser-webpack-plugin": "^5.3.10",
28+
"web-ext": "^8.4.0",
2329
"zustand": "^5.0.3"
2430
},
2531
"devDependencies": {

src/background.ts

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Types
1+
import { browserAPI } from './utils/browser-api';
22

33
enum PlatformType {
44
TWITTER = 'twitter',
@@ -460,10 +460,38 @@ class BackgroundService {
460460
};
461461
}
462462
}
463+
464+
465+
init() {
466+
browserAPI.runtime.onMessage.addListener(async (
467+
request: { type: string; username: string; platform: string },
468+
sender: any,
469+
sendResponse: (response: BuilderScoreResponse) => void
470+
) => {
471+
if (request.type === 'GET_PASSPORT_DATA') {
472+
try {
473+
const response = await this.getPassportData({
474+
username: request.username,
475+
platform: request.platform
476+
});
477+
sendResponse(response);
478+
} catch (error) {
479+
console.error('Error in background:', error);
480+
sendResponse({
481+
success: false,
482+
error: error instanceof Error ? error.message : 'Unknown error occurred'
483+
});
484+
}
485+
}
486+
return true; // Keep message channel open for async response
487+
});
488+
}
489+
463490
}
464491

465492
// Initialize the background service
466493
const backgroundService = new BackgroundService();
494+
backgroundService.init();
467495

468496
// Chrome extension message listener
469497
chrome.runtime.onMessage.addListener((

0 commit comments

Comments
 (0)