Recently Opera browser removed paste & go feature (via ctrl+shift+v), so I'm trying to implement an extension that can do the same. The following code (in the background script) works:
chrome.commands.onCommand.addListener((e) => {
var pasteTarget = document.createElement('div');
pasteTarget.contentEditable = true;
var actElem = document.activeElement.appendChild(pasteTarget).parentNode;
pasteTarget.focus();
document.execCommand('paste');
var paste = pasteTarget.innerText;
chrome.tabs.update({ url: paste })
actElem.removeChild(pasteTarget);
})
However, I noticed that chrome.tabs.update({ url: paste }) is very slow, like 500 ms or so. Is there a quicker way to read clipboard and use it as a URL?