mirror of
https://github.com/GoogleChrome/chrome-extensions-samples.git
synced 2026-03-27 13:29:34 +07:00
* 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 <oliver@oliverdunk.com>
26 lines
841 B
JavaScript
26 lines
841 B
JavaScript
// Popover API https://chromestatus.com/feature/5463833265045504
|
|
|
|
(async () => {
|
|
const nav = document.querySelector('.upper-tabs > nav');
|
|
|
|
const { tip } = await chrome.runtime.sendMessage({ greeting: 'tip' });
|
|
|
|
const tipWidget = createDomElement(`
|
|
<button type="button" popovertarget="tip-popover" popovertargetaction="show" style="padding: 0 12px; height: 36px;">
|
|
<span style="display: block; font: var(--devsite-link-font,500 14px/20px var(--devsite-primary-font-family));">Tip</span>
|
|
</button>
|
|
`);
|
|
|
|
const popover = createDomElement(
|
|
`<div id='tip-popover' popover style="margin: auto;">${tip}</div>`
|
|
);
|
|
|
|
document.body.append(popover);
|
|
nav.append(tipWidget);
|
|
})();
|
|
|
|
function createDomElement(html) {
|
|
const dom = new DOMParser().parseFromString(html, 'text/html');
|
|
return dom.body.firstElementChild;
|
|
}
|