[英]How close and open same browser session firefox or chrome extension
I am trying to close and open same session in my browser with an extension of firefox then i have this code that close the browser and then open the last session, but the problem it is that open another window too. 我试图在浏览器中使用firefox扩展名关闭并打开相同的会话,然后使用这段代码关闭浏览器,然后打开上一个会话,但是问题是也打开了另一个窗口。 I need only open the last session whitout the other window.
我只需要打开其他窗口中的上一个会话即可。
My code in JS: 我在JS中的代码:
function close(){
var gettingAll = browser.windows.getAll({
populate: true,
windowTypes: ["normal"]
});
gettingAll.then((windows) => {
for (var item of windows) {
browser.windows.remove(item.id);
}
});
}
function restartSession {
close();
browser.windows.create().then(function (currentWindow) {
browser.sessions.restore();
});
}
Browsers will naturally open a new tab once their are up. 浏览器启动后自然会打开一个新选项卡。
This cannot be avoided, but you could write a js code to close the blank tab once the document is ready. 这无法避免,但是您可以编写js代码以在文档准备好后关闭空白标签。
So basically the tab would open but close right away, within a second. 因此,基本上,该选项卡会在一秒钟内打开但立即关闭。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.