6 Commits

Author SHA1 Message Date
7d90f5d5bf ci: fix release script 2025-10-08 11:21:47 +03:00
a68f2ddbe8 ci: test release action 2025-10-08 11:18:54 +03:00
2a1034aef4 fix (ci): keep update-manifest-versions script in vanilla js 2025-10-08 11:16:31 +03:00
1ec17cd83e chore: migrated to typescript 2025-10-08 11:09:16 +03:00
b5386c706f fixed eslint config 2025-10-08 10:32:59 +03:00
5ca83fce0f fix npm install 2025-10-08 10:31:48 +03:00
15 changed files with 322 additions and 31 deletions

View File

@@ -16,13 +16,25 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build extension
run: npm run build
- name: Set version from tag - name: Set version from tag
id: version id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Create zip package - name: Create zip package
run: | run: |
zip -r goose-highlighter.zip . -x '*.git*' 'node_modules/*' 'versioning.md' '.releaserc.json' 'package.json' 'package-lock.json' 'README.md' zip -r goose-highlighter.zip . -x '*.git*' 'node_modules/*' 'src/*' 'versioning.md' '.releaserc.json' 'package.json' 'package-lock.json' 'README.md' 'tsconfig.json' 'eslint.config.mjs'
- name: Install webstore upload CLI - name: Install webstore upload CLI
run: npm install -g chrome-webstore-upload-cli run: npm install -g chrome-webstore-upload-cli

103
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,103 @@
name: Create GitHub Release
on:
push:
tags:
- 'v*'
jobs:
release:
name: Create Release with Extension Files
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build extension
run: npm run build
- name: Get version from tag
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Update manifest version
run: node scripts/update-manifest-version.js ${{ steps.version.outputs.VERSION }}
- name: Create extension zip
run: |
zip -r goose-highlighter-${{ steps.version.outputs.VERSION }}.zip . \
-x '*.git*' 'node_modules/*' 'src/*' 'versioning.md' '.releaserc.json' \
'package.json' 'package-lock.json' 'README.md' 'tsconfig.json' \
'eslint.config.mjs' '.github/*' 'CHANGELOG.md' 'PRIVACY.MD'
- name: Install Chrome extension packaging tool
run: npm install -g crx3
- name: Generate private key for CRX
run: |
openssl genrsa -out key.pem 2048
- name: Create CRX file
run: |
# Create a temporary directory for the extension
mkdir temp_extension
# Copy all files except excluded ones to temp directory
rsync -av --exclude='.git*' --exclude='node_modules' --exclude='src' \
--exclude='versioning.md' --exclude='.releaserc.json' \
--exclude='package.json' --exclude='package-lock.json' \
--exclude='README.md' --exclude='tsconfig.json' \
--exclude='eslint.config.mjs' --exclude='.github' \
--exclude='CHANGELOG.md' --exclude='PRIVACY.MD' \
--exclude='key.pem' --exclude='temp_extension' \
./ temp_extension/
# Create CRX file
crx3 temp_extension -o goose-highlighter-${{ steps.version.outputs.VERSION }}.crx -p key.pem
# Clean up
rm -rf temp_extension key.pem
- name: Generate release notes
id: release_notes
run: |
if [ -f CHANGELOG.md ]; then
# Extract the latest version's changes from CHANGELOG.md
awk '/^## \[${{ steps.version.outputs.VERSION }}\]/{flag=1; next} /^## \[/{flag=0} flag' CHANGELOG.md > release_notes.txt
if [ -s release_notes.txt ]; then
echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
cat release_notes.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
else
echo "RELEASE_NOTES=Release ${{ steps.version.outputs.VERSION }}" >> $GITHUB_OUTPUT
fi
else
echo "RELEASE_NOTES=Release ${{ steps.version.outputs.VERSION }}" >> $GITHUB_OUTPUT
fi
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ steps.version.outputs.VERSION }}
body: ${{ steps.release_notes.outputs.RELEASE_NOTES }}
files: |
goose-highlighter-${{ steps.version.outputs.VERSION }}.zip
goose-highlighter-${{ steps.version.outputs.VERSION }}.crx
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2
.gitignore vendored
View File

@@ -1 +1,3 @@
node_modules node_modules
dist

View File

@@ -1,18 +0,0 @@
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.status === 'complete' && /^https?:/.test(tab.url)) {
chrome.scripting.executeScript({
target: { tabId },
files: ['main.js']
}).catch(err => {
console.warn('Injection failed:', err);
});
}
});
chrome.runtime.onInstalled.addListener(() => {
chrome.storage.local.get(['exceptionsList'], (result) => {
if (!result.exceptionsList) {
chrome.storage.local.set({ exceptionsList: [] });
}
});
});

View File

@@ -28,4 +28,13 @@ export default [...compat.extends('eslint:recommended'), {
semi: ['error', 'always'], semi: ['error', 'always'],
quotes: ['error', 'single'], quotes: ['error', 'single'],
}, },
}, {
files: ['scripts/**/*.js'],
languageOptions: {
globals: {
...globals.node,
},
ecmaVersion: 12,
sourceType: 'module',
},
}]; }];

View File

@@ -17,7 +17,7 @@
"default_icon": "icons/icon128.png" "default_icon": "icons/icon128.png"
}, },
"background": { "background": {
"service_worker": "background.js" "service_worker": "dist/background.js"
}, },
"icons": { "icons": {
"48": "icons/icon48.png", "48": "icons/icon48.png",

53
package-lock.json generated
View File

@@ -10,9 +10,11 @@
"@semantic-release/changelog": "^6.0.3", "@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^7.1.0", "@semantic-release/exec": "^7.1.0",
"@semantic-release/git": "^10.0.1", "@semantic-release/git": "^10.0.1",
"@types/chrome": "^0.0.270",
"eslint": "^9.30.0", "eslint": "^9.30.0",
"globals": "^16.2.0", "globals": "^16.2.0",
"semantic-release": "^24.2.5" "semantic-release": "^24.2.5",
"typescript": "^5.6.0"
} }
}, },
"node_modules/@babel/code-frame": { "node_modules/@babel/code-frame": {
@@ -1213,6 +1215,17 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/@types/chrome": {
"version": "0.0.270",
"resolved": "https://registry.npmjs.org/@types/chrome/-/chrome-0.0.270.tgz",
"integrity": "sha512-ADvkowV7YnJfycZZxL2brluZ6STGW+9oKG37B422UePf2PCXuFA/XdERI0T18wtuWPx0tmFeZqq6MOXVk1IC+Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/filesystem": "*",
"@types/har-format": "*"
}
},
"node_modules/@types/estree": { "node_modules/@types/estree": {
"version": "1.0.8", "version": "1.0.8",
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz",
@@ -1220,6 +1233,30 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/@types/filesystem": {
"version": "0.0.36",
"resolved": "https://registry.npmjs.org/@types/filesystem/-/filesystem-0.0.36.tgz",
"integrity": "sha512-vPDXOZuannb9FZdxgHnqSwAG/jvdGM8Wq+6N4D/d80z+D4HWH+bItqsZaVRQykAn6WEVeEkLm2oQigyHtgb0RA==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/filewriter": "*"
}
},
"node_modules/@types/filewriter": {
"version": "0.0.33",
"resolved": "https://registry.npmjs.org/@types/filewriter/-/filewriter-0.0.33.tgz",
"integrity": "sha512-xFU8ZXTw4gd358lb2jw25nxY9QAgqn2+bKKjKOYfNCzN4DKCFetK7sPtrlpg66Ywe3vWY9FNxprZawAh9wfJ3g==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/har-format": {
"version": "1.2.16",
"resolved": "https://registry.npmjs.org/@types/har-format/-/har-format-1.2.16.tgz",
"integrity": "sha512-fluxdy7ryD3MV6h8pTfTYpy/xQzCFC7m89nOH9y94cNqJ1mDIDPut7MnRHI3F6qRmh/cT2fUjG1MLdCNb4hE9A==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/json-schema": { "node_modules/@types/json-schema": {
"version": "7.0.15", "version": "7.0.15",
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
@@ -7624,6 +7661,20 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/typescript": {
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
},
"node_modules/uglify-js": { "node_modules/uglify-js": {
"version": "3.19.3", "version": "3.19.3",
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz",

View File

@@ -5,11 +5,17 @@
"@semantic-release/changelog": "^6.0.3", "@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^7.1.0", "@semantic-release/exec": "^7.1.0",
"@semantic-release/git": "^10.0.1", "@semantic-release/git": "^10.0.1",
"@types/chrome": "^0.0.270",
"eslint": "^9.30.0", "eslint": "^9.30.0",
"globals": "^16.2.0", "globals": "^16.2.0",
"semantic-release": "^24.2.5" "semantic-release": "^24.2.5",
"typescript": "^5.6.0"
}, },
"scripts": { "scripts": {
"prepare": "node scripts/update-manifest-version.js" "build": "tsc",
"watch": "tsc --watch",
"clean": "rimraf dist",
"rebuild": "npm run clean && npm run build",
"prepare": "npm run build && node scripts/update-manifest-version.js"
} }
} }

View File

@@ -148,8 +148,7 @@
</div> </div>
</div> </div>
<script src="../storage.js"></script> <script src="../dist/popup/popup.js"></script>
<script src="popup.js"></script>
</body> </body>
</html> </html>

View File

@@ -1,13 +1,13 @@
const fs = require("fs"); const fs = require('fs');
const version = process.argv[2]; const version = process.argv[2];
if (!version) { if (!version) {
console.error("❌ No version passed"); console.log(' No version passed, skipping manifest update');
process.exit(1); process.exit(0);
} }
const manifest = JSON.parse(fs.readFileSync("manifest.json", "utf-8")); const manifest = JSON.parse(fs.readFileSync('manifest.json', 'utf-8'));
manifest.version = version; manifest.version = version;
fs.writeFileSync("manifest.json", JSON.stringify(manifest, null, 2)); fs.writeFileSync('manifest.json', JSON.stringify(manifest, null, 2));
console.log(`✅ Updated manifest.json to version ${version}`); console.log(`✅ Updated manifest.json to version ${version}`);

20
src/background.ts Normal file
View File

@@ -0,0 +1,20 @@
// Handle tab updates to inject content script
chrome.tabs.onUpdated.addListener((tabId: number, changeInfo: chrome.tabs.TabChangeInfo, tab: chrome.tabs.Tab): void => {
if (changeInfo.status === 'complete' && tab.url && /^https?:/.test(tab.url)) {
chrome.scripting.executeScript({
target: { tabId },
files: ['dist/main.js']
}).catch((err: unknown) => {
console.warn('Injection failed:', err);
});
}
});
// Initialize storage on extension install
chrome.runtime.onInstalled.addListener((): void => {
chrome.storage.local.get(['exceptionsList'], (result: any) => {
if (!result.exceptionsList) {
chrome.storage.local.set({ exceptionsList: [] });
}
});
});

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
let currentLists = []; let currentLists = [];
let isGlobalHighlightEnabled = true; let isGlobalHighlightEnabled = true;
let exceptionsList = []; let exceptionsList = [];

View File

@@ -1,3 +1,4 @@
// @ts-nocheck
const listSelect = document.getElementById('listSelect'); const listSelect = document.getElementById('listSelect');
const listName = document.getElementById('listName'); const listName = document.getElementById('listName');
const listBg = document.getElementById('listBg'); const listBg = document.getElementById('listBg');

75
src/types.ts Normal file
View File

@@ -0,0 +1,75 @@
// Type definitions for the Goose Highlighter extension
export interface HighlightWord {
wordStr: string;
background: string;
foreground: string;
active: boolean;
}
export interface HighlightList {
id: number;
name: string;
background: string;
foreground: string;
active: boolean;
words: HighlightWord[];
}
export interface StorageData {
lists: HighlightList[];
globalHighlightEnabled: boolean;
matchCaseEnabled: boolean;
matchWholeEnabled: boolean;
exceptionsList: string[];
}
export interface ActiveWord {
text: string;
background: string;
foreground: string;
}
export interface MessageData {
type: 'WORD_LIST_UPDATED' | 'GLOBAL_TOGGLE_UPDATED' | 'MATCH_OPTIONS_UPDATED' | 'EXCEPTIONS_LIST_UPDATED';
enabled?: boolean;
matchCase?: boolean;
matchWhole?: boolean;
}
export interface SectionStates {
[sectionName: string]: boolean;
}
export interface ExportData {
lists: HighlightList[];
exceptionsList: string[];
}
// DOM element selectors used in popup
export interface PopupElements {
listSelect: HTMLSelectElement;
listName: HTMLInputElement;
listBg: HTMLInputElement;
listFg: HTMLInputElement;
listActive: HTMLInputElement;
bulkPaste: HTMLTextAreaElement;
wordList: HTMLDivElement;
importInput: HTMLInputElement;
matchCase: HTMLInputElement;
matchWhole: HTMLInputElement;
}
// Default storage values
export const DEFAULT_STORAGE: Partial<StorageData> = {
lists: [],
globalHighlightEnabled: true,
matchCaseEnabled: false,
matchWholeEnabled: false,
exceptionsList: []
};
// Constants
export const WORD_ITEM_HEIGHT = 32;
export const DEBOUNCE_DELAY = 300;
export const SCROLL_THROTTLE = 16; // ~60fps

30
tsconfig.json Normal file
View File

@@ -0,0 +1,30 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "CommonJS",
"lib": ["ES2022", "DOM"],
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"noEmitOnError": false,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"exactOptionalPropertyTypes": false,
"types": ["chrome"]
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"dist"
]
}