incognito window first
This commit is contained in:
@ -22,7 +22,7 @@ export function redirectTab(tab: chrome.tabs.Tab, url: string) {
|
|||||||
}
|
}
|
||||||
if (newURL == url) return url;
|
if (newURL == url) return url;
|
||||||
if (
|
if (
|
||||||
tryCount % 5 == 0 &&
|
tryCount % 1 == 0 &&
|
||||||
!confirm('Cannot navigate to target url. \nPress OK to continue, Cancel to stop.')
|
!confirm('Cannot navigate to target url. \nPress OK to continue, Cancel to stop.')
|
||||||
) {
|
) {
|
||||||
return Promise.reject("Tasks stopped by user.");
|
return Promise.reject("Tasks stopped by user.");
|
||||||
@ -101,13 +101,51 @@ export function scrollToBottom(tab: chrome.tabs.Tab) {
|
|||||||
|
|
||||||
export async function createTab(url: string, active: boolean) {
|
export async function createTab(url: string, active: boolean) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
findIncognitoWindow().then(
|
||||||
|
incognitoWindow => {
|
||||||
chrome.tabs.create({
|
chrome.tabs.create({
|
||||||
'url': url,
|
'url': url,
|
||||||
'active': active
|
'active': active,
|
||||||
|
// createTab to incognito window first
|
||||||
|
'windowId': incognitoWindow ? incognitoWindow.id : undefined
|
||||||
}, function (tab) {
|
}, function (tab) {
|
||||||
resolve(tab);
|
resolve(tab);
|
||||||
})
|
})
|
||||||
})
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function findIncognitoWindow(): Promise<chrome.windows.Window> {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
chrome.windows.getAll(
|
||||||
|
{
|
||||||
|
windowTypes: ['normal'],
|
||||||
|
},
|
||||||
|
(windows: chrome.windows.Window[]) => {
|
||||||
|
for (let window of windows) {
|
||||||
|
if (window.incognito) {
|
||||||
|
resolve(window);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resolve(undefined);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function CreateIncognitoWindow() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
chrome.windows.create(
|
||||||
|
<chrome.windows.CreateData>{
|
||||||
|
incognito: true,
|
||||||
|
},
|
||||||
|
(window: chrome.windows.Window) => {
|
||||||
|
resolve(window);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getActiveTab(currentWindow: boolean) {
|
export async function getActiveTab(currentWindow: boolean) {
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
],
|
],
|
||||||
"run_at": "document_idle"
|
"run_at": "document_idle"
|
||||||
}],
|
}],
|
||||||
|
"incognito": "spanning",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"activeTab",
|
"activeTab",
|
||||||
"notifications"
|
"notifications"
|
||||||
|
|||||||
Reference in New Issue
Block a user