From b9df791e765a243c47feda49a48eeb8196434ecc Mon Sep 17 00:00:00 2001 From: Pasquale Riello Date: Tue, 27 Feb 2024 15:07:16 +0100 Subject: [PATCH] Fix #1084: quick-api-reference sample (#1099) * Add README.md * Fix issue related to website update Updated CSS selector and tweaked the TIP button * Update content.js Keeping newline * Update CSS styles Change padding, height and font sizes to make the button style more consistent with the navigation bar * Update functional-samples/tutorial.quick-api-reference/content.js * Update functional-samples/tutorial.quick-api-reference/README.md * Update functional-samples/tutorial.quick-api-reference/README.md --------- Co-authored-by: Oliver Dunk --- .../tutorial.quick-api-reference/README.md | 18 ++++++++++++++++++ .../tutorial.quick-api-reference/content.js | 13 ++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 functional-samples/tutorial.quick-api-reference/README.md diff --git a/functional-samples/tutorial.quick-api-reference/README.md b/functional-samples/tutorial.quick-api-reference/README.md new file mode 100644 index 0000000000..49f7a7c27c --- /dev/null +++ b/functional-samples/tutorial.quick-api-reference/README.md @@ -0,0 +1,18 @@ +# Tutorial: Handling events + +This sample demonstrates how to handle events with service workers. + +## Overview + +The extension built allows users to quickly navigate to Chrome API reference pages using the omnibox. + +The events from the following APIs have been handled: `chrome.runtime`, `chrome.omnibox` and `chrome.alarms`. + +The complete tutorial is available [here](https://developer.chrome.com/docs/extensions/get-started/tutorial/service-worker-events). + +## 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. Type "api" in the omnibox followed by tab or space and select a suggestion. +4. Click on "Tip" button in the navigation bar. \ No newline at end of file diff --git a/functional-samples/tutorial.quick-api-reference/content.js b/functional-samples/tutorial.quick-api-reference/content.js index 1a5f65d449..c22f760fa5 100644 --- a/functional-samples/tutorial.quick-api-reference/content.js +++ b/functional-samples/tutorial.quick-api-reference/content.js @@ -1,23 +1,18 @@ // Popover API https://chromestatus.com/feature/5463833265045504 (async () => { - const nav = document.querySelector('.navigation-rail__links'); + const nav = document.querySelector('.upper-tabs > nav'); const { tip } = await chrome.runtime.sendMessage({ greeting: 'tip' }); const tipWidget = createDomElement(` - `); const popover = createDomElement( - `
${tip}
` + `
${tip}
` ); document.body.append(popover);