I am creating an extension that will launch an external script based on highlighted text. So, far, the script works, except I am having issues closing the newly created window.
In my background.html, I have the following:
<script>
function executeScript(selection) {
var queryText = 'script:' + selectedText;
chrome.tabs.create({url: queryText});
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.remove(tab.id);
});
}
</script>
My problem is with the setup above, it closes the tab before the "url" loads, so it never executes the script.
If I take out the getSelected lines (lines 5-7), it opens the tab and runs the script perfectly. I am trying to just get the syntax to close the tab automatically after it executes.
Thanks!