简体   繁体   English

如何调整隐身模式并在现有隐身 window 中打开新选项卡?

[英]How to regconize incognito mode and open new tab in an existing incognito window?

i am not professional developer.我不是专业的开发人员。 and i just make one Chrome extension app.我只制作了一个 Chrome 扩展应用程序。 https://chrome.google.com/webstore/detail/%EB%84%A4%EC%9D%B4%EB%B2%84-%EA%B2%80%EC%83%89/bkkebjanfcchfakehopacbbpogflmdie?utm_source=chrome-ntp-icon https://chrome.google.com/webstore/detail/%EB%84%A4%EC%9D%B4%EB%B2%84-%EA%B2%80%EC%83%89/bkkebjanfcchfakehopacbbpogflmdie?utm_source= chrome-ntp-图标

This app just makes CONTEXT MENU and open window new chrome tab.这个应用程序只是制作上下文菜单并打开 window 新的 chrome 标签。 but one of my user wants me to make this app works in incognito mode.但我的一位用户希望我让这个应用程序在隐身模式下运行。 (open window with incognito mode) (以隐身模式打开 window)

i really tried many times.我真的试过很多次。 but i can`t understand how to recognize incognito mode and how to make new incognito tab in same window.但我不明白如何识别隐身模式以及如何在同一个 window 中创建新的隐身标签。 This is my last try and please help me... thanks这是我最后一次尝试,请帮助我...谢谢

chrome.extension.isAllowedIncognitoAccess(function(isAllowedAccess) 
{
 if (isAllowedAccess) return;
  window.open("http://search.naver.com/search.naver?ie=utf8&query=" + itemData.selectionText, '_blank');
});

The context menu listener receives a tab object in the second parameter so let's reuse its windowId property via chrome.tabs.create :上下文菜单监听器在第二个参数中接收到一个选项卡object,所以让我们通过chrome.tabs.create重用它的windowId属性:

chrome.contextMenus.onClicked.addListener((info, tab) => {
  chrome.tabs.create({
    url: 'http://search.naver.com/search.naver?ie=utf8&query=' +
      encodeURIComponent(info.selectionText),
    windowId: tab.windowId,
    openerTabId: tab.id,
  });
});

PS With openerTabId , when this new tab will be closed by the user, the focus will be automatically set to the specified tab regardless of its relative position in the tab strip. PS 使用openerTabId ,当用户关闭此新选项卡时,焦点将自动设置到指定选项卡,而不管其在选项卡条中的相对 position。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM