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
35 changes: 21 additions & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
env: {}

# FILE GENERATED WITH: npx ghat fregante/ghatemplates/node
# SOURCE: https://github.com/fregante/ghatemplates
# OPTIONS: {"exclude":["jobs.Test"]}
# FILE GENERATED WITH: npx ghat fregante/content-scripts-register-polyfill/.github/workflows/ci.yml
# SOURCE: https://github.com/fregante/content-scripts-register-polyfill

name: Test

name: CI
on:
- pull_request
- push

jobs:
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install
run: npm ci || npm install
- name: XO
run: npx xo
- uses: actions/checkout@v3
- run: npm ci
- run: npx xo

Build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: install
run: npm ci || npm install
- name: build
run: npm run build
- uses: actions/checkout@v3
- run: npm ci
- run: npm run build
- run: npm run demo:build

Test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: sudo apt-get install xvfb
- run: npm ci
- run: xvfb-run --auto-servernum npm run jest
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ logs
*.map
index.js
index.d.ts
.parcel-cache
dist
1 change: 0 additions & 1 deletion .npmrc

This file was deleted.

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"
}
15 changes: 5 additions & 10 deletions how-to-add-github-enterprise-support-to-web-extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ import addDomainPermissionToggle from 'webext-domain-permission-toggle';
addDomainPermissionToggle();
```

## manifest.json example
## manifest.json v2 example

```js
{
"version": 2,
"permissions": [
"https://github.com/*",
"contextMenus",
Expand All @@ -49,15 +50,9 @@ addDomainPermissionToggle();
},
"content_scripts": [
{
"matches": [
"https://github.com/*"
],
"css": [
"content.css"
],
"js": [
"content.js"
]
"matches": ["https://github.com/*"],
"css": ["content.css"],
"js": ["content.js"]
}
]
}
Expand Down
8 changes: 5 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function convertPath(file: string): browser.extensionTypes.ExtensionFileOrCode {
return {file: url.pathname};
}

function injectOnExistingTabs(origins: string[], scripts: ContentScripts) {
function injectToExistingTabs(origins: string[], scripts: ContentScripts) {
if (origins.length === 0) {
return;
}
Expand All @@ -42,7 +42,7 @@ async function registerOnOrigins({
const manifest = chrome.runtime.getManifest().content_scripts;

if (!manifest) {
throw new Error('webext-dynamic-content-scripts tried to register scripts on th new host permissions, but no content scripts were found in the manifest.');
throw new Error('webext-dynamic-content-scripts tried to register scripts on the new host permissions, but no content scripts were found in the manifest.');
}

// Register one at a time to allow removing one at a time as well
Expand All @@ -60,7 +60,9 @@ async function registerOnOrigins({
}
}

injectOnExistingTabs(newOrigins || [], manifest);
// May not be needed in the future in Firefox
// https://bugzilla.mozilla.org/show_bug.cgi?id=1458947
injectToExistingTabs(newOrigins || [], manifest);
}

(async () => {
Expand Down
11 changes: 11 additions & 0 deletions jest-puppeteer.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const path = require('path');

module.exports = {
launch: {
headless: false,
args: [
'--disable-extensions-except=' + path.resolve(__dirname, 'test/dist'),
'--window-size=400,800',
],
},
};
Loading