Changes onInstalled event listener to action.onClicked (#971)
* Changes onInstalled event listener to action.onClicked * Update sandbox.html * Update sandbox.html
This commit is contained in:
Родитель
7e067289c4
Коммит
307da41987
|
@ -3,12 +3,13 @@
|
|||
"version": "1.0.3",
|
||||
"manifest_version": 3,
|
||||
"background": {
|
||||
"service_worker": "service-worker.js"
|
||||
},
|
||||
"service_worker": "service-worker.js"
|
||||
},
|
||||
"icons": {
|
||||
"128": "icon_128.png"
|
||||
},
|
||||
"sandbox": {
|
||||
"pages": ["sandbox.html"]
|
||||
}
|
||||
},
|
||||
"action": {}
|
||||
}
|
||||
|
|
|
@ -57,13 +57,11 @@ limitations under the License.
|
|||
// Set up message event handler:
|
||||
window.addEventListener('message', function (event) {
|
||||
const command = event.data.command;
|
||||
let template = templates[event.data.templateName],
|
||||
const template = templates[event.data.templateName],
|
||||
result = 'invalid request';
|
||||
|
||||
// if we don't know the templateName requested, return an error message
|
||||
if (!template) {
|
||||
result = 'Unknown template: ' + event.data.templateName;
|
||||
} else {
|
||||
if (template) {
|
||||
switch (command) {
|
||||
case 'render':
|
||||
result = template(event.data.context);
|
||||
|
@ -75,6 +73,8 @@ limitations under the License.
|
|||
// result = template(event.data.context);
|
||||
// break;
|
||||
}
|
||||
} else {
|
||||
result = 'Unknown template: ' + event.data.templateName;
|
||||
}
|
||||
event.source.postMessage({ result: result }, event.origin);
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
* @see http://developer.chrome.com/docs/extensions/reference/runtime
|
||||
* @see http://developer.chrome.com/docs/extensions/reference/tabs
|
||||
*/
|
||||
chrome.runtime.onInstalled.addListener(() => {
|
||||
chrome.action.onClicked.addListener(() => {
|
||||
chrome.tabs.create({
|
||||
url: 'mainpage.html'
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче