Files
chrome-extensions-samples/api-samples/alarms/background.js
2023-06-06 09:28:50 -05:00

27 lines
679 B
JavaScript

// Copyright 2021 Google LLC
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
// Initialize the demo on install
chrome.runtime.onInstalled.addListener(({ reason }) => {
if (reason !== chrome.runtime.OnInstalledReason.INSTALL) {
return;
}
openDemoTab();
// Create an alarm so we have something to look at in the demo
chrome.alarms.create('demo-default-alarm', {
delayInMinutes: 1,
periodInMinutes: 1
});
});
chrome.action.onClicked.addListener(openDemoTab);
function openDemoTab() {
chrome.tabs.create({ url: 'index.html' });
}