Skip to content

Commit

Permalink
feat: allow enabling extension on custom domains (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
uncenter authored Jul 3, 2024
1 parent b57bf43 commit d274322
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
with:
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
node-version-file: '.nvmrc'

- name: Install dependencies
run: pnpm install --frozen-lockfile
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
with:
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
node-version-file: '.nvmrc'

- name: Install dependencies
run: pnpm install --frozen-lockfile
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"license": "MIT",
"dependencies": {
"@catppuccin/palette": "1.2.0",
"selector-observer": "2.1.6"
"selector-observer": "2.1.6",
"webext-dynamic-content-scripts": "10.0.3",
"webext-permission-toggle": "5.0.1"
},
"devDependencies": {
"@humanfs/node": "0.16.3",
Expand Down
104 changes: 104 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/entries/background/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// See https://github.com/fregante/webext-dynamic-content-scripts/blob/main/how-to-add-github-enterprise-support-to-web-extensions.md.
import 'webext-dynamic-content-scripts';
import addPermissionToggle from 'webext-permission-toggle';

export default defineBackground({
main() {
addPermissionToggle();
},
});
2 changes: 2 additions & 0 deletions src/entries/content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { flavor } from '@/storage';
import { replaceIconInRow, injectStyles } from './lib';

export default defineContentScript({
// Make sure this value is updated in wxt.config.ts as well.
matches: ['*://github.com/*', '*://gitlab.com/*', '*://codeberg.org/*'],
runAt: 'document_start',

main() {
// Replacing all icons synchronously prevents visual "blinks" but can
// cause missing icons/rendering delay in very large folders.
Expand Down
1 change: 1 addition & 0 deletions web-ext.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ export default defineRunnerConfig({
'https://github.com/catppuccin/catppuccin',
'https://gitlab.com/gitlab-org/gitlab',
'https://codeberg.org/forgejo/forgejo',
'https://gitea.catppuccin.com/catppuccin/catppuccin',
],
});
17 changes: 16 additions & 1 deletion wxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,22 @@ export default defineConfig({
outDir: 'dist',
manifest: {
name: 'Catppuccin for GitHub File Explorer Icons',
permissions: ['storage'],
// See https://github.com/fregante/webext-dynamic-content-scripts/blob/main/how-to-add-github-enterprise-support-to-web-extensions.md.
permissions: ['storage', 'scripting', 'contextMenus', 'activeTab'],
// @ts-expect-error: Now in browsers (see https://github.com/w3c/webextensions/issues/119).
optional_host_permissions: ['*://*/*'],
// Make sure to update in src/entries/content/index.ts as well.
content_scripts: [
{
matches: [
'*://codeberg.org/*',
'*://github.com/*',
'*://gitlab.com/*',
],
run_at: 'document_start',
js: ['content-scripts/content.js'],
},
],
homepage_url:
'https://github.com/catppuccin/github-file-explorer-icons',
},
Expand Down

0 comments on commit d274322

Please sign in to comment.