Paste from Clipboard

I added “clipboardRead” to permissions to my extension, but can’t find right way to use it. My javascript file:

browser.browserAction.onClicked.addListener(function() {
// Returns: false
//var item = “https://www.google.com/search?q=” + String(document.execCommand(“copy”));

// Returns: true
//let item = “https://www.google.com/search?q=” + document.execCommand(“paste”);

// Returns: [object Promise]
let item = “https://www.google.com/search?q=” + navigator.clipboard.readText();

// Returns nothing
//let item = “https://www.google.com/search?q” + await this.getClipboardText();

var creating = browser.tabs.create({
url: item
});
creating.then(onCreated, onError);
});

The easiest way to get the text contents of the clipboard without using HTML elements is
https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/readText

Thank you! Got code partially working. Can use only URLs from clipboard. Now need to find a way to compare if clipboard contains URL or some other text string and that case to start google search.

Current code

navigator.clipboard.readText().then(
    clipText => browser.tabs.create({
        url:clipText
    })
)

You could use the URL constructor to detect strings that aren’t valid URLs, since it throws in that case:
https://developer.mozilla.org/en-US/docs/Web/API/URL/URL