I'm working on a solution to close and open the same session in my browser using a Firefox extension. The code I have currently closes the browser and then opens the last session, but it also opens another window which is not desired. I want to be able to open just the last session without opening an additional window.
Here's my JavaScript code:
function closeBrowser(){
var gettingAll = browser.windows.getAll({
populate: true,
windowTypes: ["normal"]
});
gettingAll.then((windows) => {
for (var item of windows) {
browser.windows.remove(item.id);
}
});
}
function restartSession {
closeBrowser();
browser.windows.create().then(function (currentWindow) {
browser.sessions.restore();
});
}