Skip to content

Commit

Permalink
Exclude discarded tabs; inject tabs progressively (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante authored Dec 29, 2023
1 parent 5d2f2ad commit 6ff1264
Show file tree
Hide file tree
Showing 22 changed files with 9,697 additions and 113 deletions.
5 changes: 1 addition & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{package.json,*.yml}]
[*.yml]
indent_style = space
indent_size = 2

[*.md]
trim_trailing_whitespace = false
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Test

on:
- pull_request
- push

jobs:
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
- run: npm ci
- run: npx xo

Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: package.json
- run: npm ci
- run: npm run prepack

Demo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version-file: package.json
- run: npm ci
- run: npm run demo:build
88 changes: 88 additions & 0 deletions .github/workflows/esm-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
env:
IMPORT_TEXT: import
NPM_MODULE_NAME: webext-inject-on-install

# FILE GENERATED WITH: npx ghat fregante/ghatemplates/esm-lint
# SOURCE: https://github.com/fregante/ghatemplates
# OPTIONS: {"exclude":["jobs.Parcel"]}

name: ESM
on:
pull_request:
branches:
- '*'
push:
branches:
- master
- main
jobs:
Pack:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm install
- run: npm run build --if-present
- run: npm pack --dry-run
- run: npm pack | tail -1 | xargs -n1 tar -xzf
- uses: actions/upload-artifact@v3
with:
path: package
Webpack:
runs-on: ubuntu-latest
needs: Pack
steps:
- uses: actions/download-artifact@v3
- run: npm install ./artifact
- run: echo "${{ env.IMPORT_TEXT }} '${{ env.NPM_MODULE_NAME }}'" > index.js
- run: webpack --entry ./index.js
- run: cat dist/main.js
Rollup:
runs-on: ubuntu-latest
needs: Pack
steps:
- uses: actions/download-artifact@v3
- run: npm install ./artifact rollup@2 @rollup/plugin-node-resolve
- run: echo "${{ env.IMPORT_TEXT }} '${{ env.NPM_MODULE_NAME }}'" > index.js
- run: npx rollup -p node-resolve index.js
Vite:
runs-on: ubuntu-latest
needs: Pack
steps:
- uses: actions/download-artifact@v3
- run: npm install ./artifact
- run: >-
echo '<script type="module">${{ env.IMPORT_TEXT }} "${{
env.NPM_MODULE_NAME }}"</script>' > index.html
- run: npx vite build
- run: cat dist/assets/*
esbuild:
runs-on: ubuntu-latest
needs: Pack
steps:
- uses: actions/download-artifact@v3
- run: echo '{}' > package.json
- run: echo "${{ env.IMPORT_TEXT }} '${{ env.NPM_MODULE_NAME }}'" > index.js
- run: npm install ./artifact
- run: npx esbuild --bundle index.js
TypeScript:
runs-on: ubuntu-latest
needs: Pack
steps:
- uses: actions/download-artifact@v3
- run: npm install ./artifact @sindresorhus/tsconfig
- run: echo "${{ env.IMPORT_TEXT }} '${{ env.NPM_MODULE_NAME }}'" > index.ts
- run: |
echo '{"extends":"@sindresorhus/tsconfig","files":["index.ts"]}' > tsconfig.json
- run: tsc
- run: cat index.js
Node:
runs-on: ubuntu-latest
needs: Pack
steps:
- uses: actions/download-artifact@v3
- uses: actions/setup-node@v4
with:
node-version: 16
- run: echo "${{ env.IMPORT_TEXT }} '${{ env.NPM_MODULE_NAME }}'" > index.mjs
- run: npm install ./artifact
- run: node index.mjs
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Thumbs.db
*.bak
*.log
logs

*.common-js.js
*.es-modules.js
*.map
dist
distribution
.parcel-cache
3 changes: 3 additions & 0 deletions .parcelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@parcel/config-webextension"
}
3 changes: 0 additions & 3 deletions .travis.yml

This file was deleted.

1 change: 1 addition & 0 deletions demo/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'webext-inject-on-install/register';
1 change: 1 addition & 0 deletions demo/content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.count('content.js injected');
20 changes: 20 additions & 0 deletions demo/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$schema": "https://json.schemastore.org/chrome-manifest",
"name": "webext-inject-on-install",
"manifest_version": 2,
"version": "1.0.0",
"description": "Injects a script into the page when the extension is installed.",
"permissions": [
"tabs",
"https://ephiframe.vercel.app/*"
],
"content_scripts": [
{
"matches": ["https://ephiframe.vercel.app/*"],
"js": ["content.js"]
}
],
"background": {
"scripts": ["background.js"]
}
}
6 changes: 6 additions & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "module",
"alias": {
"webext-inject-on-install": "../source/"
}
}
10 changes: 10 additions & 0 deletions demo/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Test extension

Run these 2 commands in parallel to open the extension:

```sh
npm run demo:watch
npx web-ext run --target=chromium
```

Also open the background script console to see any errors.
27 changes: 0 additions & 27 deletions index.js

This file was deleted.

22 changes: 5 additions & 17 deletions license
Original file line number Diff line number Diff line change
@@ -1,21 +1,9 @@
The MIT License (MIT)
MIT License

Copyright (c) Federico Brigante <[email protected].com> (twitter.com/bfred_it)
Copyright (c) Federico Brigante <me@fregante.com> (https://fregante.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Loading

0 comments on commit 6ff1264

Please sign in to comment.