Web nav mv3 sample (#958)

* implemented webNavigation mv3 sample

* Added mv3 webNavigation API sample

* Changes based on review
This commit is contained in:
IanStanion-google
2023-06-21 14:57:59 -04:00
committed by GitHub
parent 0af4863057
commit cd11c730ea
4 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
# chrome.webNavigation
This sample demonstrates using the webNavigation API to send notifications.
## Overview
The extension calls the `chrome.webNavigation.onCompleted.addListener()` event listener to trigger a notification whenever a the user navigates to a new webpage.
## Running this extension
1. Clone this repository.
2. Load this directory in Chrome as an [unpacked extension](https://developer.chrome.com/docs/extensions/mv3/getstarted/development-basics/#load-unpacked).
3. Navigate the web with notifications on.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1001 B

View File

@@ -0,0 +1,10 @@
{
"name": "webNavigation API Sample",
"version": "2",
"description": "A demonstration of the webNavigation API",
"background": {
"service_worker": "service-worker.js"
},
"permissions": ["webNavigation", "notifications"],
"manifest_version": 3
}

View File

@@ -0,0 +1,27 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
chrome.webNavigation.onCompleted.addListener((details) => {
chrome.notifications.create({
type: 'basic',
iconUrl: 'icon.png',
title: 'page loaded',
message:
'Completed loading: ' +
details.url +
' at ' +
details.timeStamp +
' milliseconds since the epoch.'
});
});