|
@@ -31,13 +31,15 @@ singlefile.ui = (() => {
|
|
|
const MENU_ID_SAVE_PAGE = "save-page";
|
|
const MENU_ID_SAVE_PAGE = "save-page";
|
|
|
const MENU_ID_SAVE_SELECTED = "save-selected";
|
|
const MENU_ID_SAVE_SELECTED = "save-selected";
|
|
|
const MENU_ID_SAVE_FRAME = "save-frame";
|
|
const MENU_ID_SAVE_FRAME = "save-frame";
|
|
|
|
|
+ const MENU_ID_SAVE_TABS = "save-tabs";
|
|
|
|
|
+ const MENU_ID_SAVE_SELECTED_TABS = "save-selected-tabs";
|
|
|
|
|
|
|
|
const badgeTabs = {};
|
|
const badgeTabs = {};
|
|
|
const badgeRefreshPending = {};
|
|
const badgeRefreshPending = {};
|
|
|
|
|
|
|
|
browser.runtime.onInstalled.addListener(refreshContextMenu);
|
|
browser.runtime.onInstalled.addListener(refreshContextMenu);
|
|
|
if (browser.menus && browser.menus.onClicked) {
|
|
if (browser.menus && browser.menus.onClicked) {
|
|
|
- browser.menus.onClicked.addListener((event, tab) => {
|
|
|
|
|
|
|
+ browser.menus.onClicked.addListener(async (event, tab) => {
|
|
|
if (event.menuItemId == MENU_ID_SAVE_PAGE) {
|
|
if (event.menuItemId == MENU_ID_SAVE_PAGE) {
|
|
|
processTab(tab);
|
|
processTab(tab);
|
|
|
}
|
|
}
|
|
@@ -47,6 +49,14 @@ singlefile.ui = (() => {
|
|
|
if (event.menuItemId == MENU_ID_SAVE_FRAME) {
|
|
if (event.menuItemId == MENU_ID_SAVE_FRAME) {
|
|
|
processTab(tab, { frameId: event.frameId });
|
|
processTab(tab, { frameId: event.frameId });
|
|
|
}
|
|
}
|
|
|
|
|
+ if (event.menuItemId == MENU_ID_SAVE_TABS) {
|
|
|
|
|
+ const tabs = await browser.tabs.query({ currentWindow: true });
|
|
|
|
|
+ tabs.forEach(tab => isAllowedURL(tab.url) && processTab(tab));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (event.menuItemId == MENU_ID_SAVE_SELECTED_TABS) {
|
|
|
|
|
+ const tabs = await browser.tabs.query({ currentWindow: true, highlighted: true });
|
|
|
|
|
+ tabs.forEach(tab => isAllowedURL(tab.url) && processTab(tab));
|
|
|
|
|
+ }
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
browser.browserAction.onClicked.addListener(async tab => {
|
|
browser.browserAction.onClicked.addListener(async tab => {
|
|
@@ -55,7 +65,7 @@ singlefile.ui = (() => {
|
|
|
if (!tabs.length) {
|
|
if (!tabs.length) {
|
|
|
processTab(tab);
|
|
processTab(tab);
|
|
|
} else {
|
|
} else {
|
|
|
- tabs.forEach(processTab);
|
|
|
|
|
|
|
+ tabs.forEach(tab => isAllowedURL(tab.url) && processTab(tab));
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -92,15 +102,25 @@ singlefile.ui = (() => {
|
|
|
contexts: ["page"],
|
|
contexts: ["page"],
|
|
|
title: DEFAULT_TITLE
|
|
title: DEFAULT_TITLE
|
|
|
});
|
|
});
|
|
|
|
|
+ browser.menus.create({
|
|
|
|
|
+ id: MENU_ID_SAVE_TABS,
|
|
|
|
|
+ contexts: ["page"],
|
|
|
|
|
+ title: "Save all tabs"
|
|
|
|
|
+ });
|
|
|
|
|
+ browser.menus.create({
|
|
|
|
|
+ id: MENU_ID_SAVE_SELECTED_TABS,
|
|
|
|
|
+ contexts: ["page"],
|
|
|
|
|
+ title: "Save selected tabs"
|
|
|
|
|
+ });
|
|
|
browser.menus.create({
|
|
browser.menus.create({
|
|
|
id: MENU_ID_SAVE_SELECTED,
|
|
id: MENU_ID_SAVE_SELECTED,
|
|
|
contexts: ["selection"],
|
|
contexts: ["selection"],
|
|
|
- title: "Save selection with SingleFile"
|
|
|
|
|
|
|
+ title: "Save selection"
|
|
|
});
|
|
});
|
|
|
browser.menus.create({
|
|
browser.menus.create({
|
|
|
id: MENU_ID_SAVE_FRAME,
|
|
id: MENU_ID_SAVE_FRAME,
|
|
|
contexts: ["frame"],
|
|
contexts: ["frame"],
|
|
|
- title: "Save frame with SingleFile"
|
|
|
|
|
|
|
+ title: "Save frame"
|
|
|
});
|
|
});
|
|
|
} else {
|
|
} else {
|
|
|
await browser.menus.removeAll();
|
|
await browser.menus.removeAll();
|