Skip to content

Commit 4c893fb

Browse files
committed
Add support for browsers that use the WebExtension API
1 parent 7c97660 commit 4c893fb

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

generator/template/base-app/src/background.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import store from './store'
22

33
<%_ if (options.popupPage) { -%>
4-
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {<%_ } else { -%>
5-
chrome.browserAction.onClicked.addListener(function (tab) {<%_ } -%>
4+
<%- options.api %>.runtime.onMessage.addListener(function (request, sender, sendResponse) {<%_ } else { -%>
5+
<%- options.api %>.browserAction.onClicked.addListener(function (tab) {<%_ } -%>
66
console.log(`Hello ${store.getters.foo}!`)
77

88
<%_ if (options.contentScript) { -%>
9-
chrome.tabs.executeScript({
9+
<%- options.api %>.tabs.executeScript({
1010
file: 'content-script.js',
1111
});
1212
<%_ } -%>

generator/template/base-app/src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
},
3333
"options_ui": {
3434
"page": "options/options.html",
35-
"chrome_style": true
35+
"<%- options.api %>_style": true
3636
<%_ } -%>
3737
}
3838
}

generator/template/popup/src/popup/router/pages/Index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
return {}
99
},
1010
mounted () {
11-
chrome.runtime.sendMessage({});
11+
<%- options.api %>.runtime.sendMessage({})
1212
}
1313
}
1414
</script>

generator/template/standalone/src/standalone/router/pages/Index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default {
88
return {}
99
},
1010
mounted () {
11-
chrome.runtime.sendMessage({});
11+
<%- options.api %>.runtime.sendMessage({});
1212
}
1313
}
1414
</script>

prompts.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,21 @@ module.exports = [
4141

4242
return componentMap
4343
}
44+
},
45+
{
46+
name: 'api',
47+
type: 'list',
48+
default: 'browser',
49+
message: 'Which extension API do you wish to use?',
50+
choices: [
51+
{
52+
name: 'browser (WebExtension)',
53+
value: 'browser'
54+
},
55+
{
56+
name: 'chrome',
57+
value: 'chrome'
58+
}
59+
]
4460
}
4561
]

0 commit comments

Comments
 (0)