|
@@ -65,7 +65,12 @@ export {
|
|
|
|
|
|
|
|
async function saveSelectedLinks(tab) {
|
|
async function saveSelectedLinks(tab) {
|
|
|
const tabOptions = { extensionScriptFiles, tabId: tab.id, tabIndex: tab.index };
|
|
const tabOptions = { extensionScriptFiles, tabId: tab.id, tabIndex: tab.index };
|
|
|
- const scriptsInjected = await injectScript(tab.id, tabOptions);
|
|
|
|
|
|
|
+ let scriptsInjected;
|
|
|
|
|
+ try {
|
|
|
|
|
+ scriptsInjected = await injectScript(tab.id, tabOptions);
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ // ignored
|
|
|
|
|
+ }
|
|
|
if (scriptsInjected) {
|
|
if (scriptsInjected) {
|
|
|
const response = await browser.tabs.sendMessage(tab.id, { method: "content.getSelectedLinks" });
|
|
const response = await browser.tabs.sendMessage(tab.id, { method: "content.getSelectedLinks" });
|
|
|
if (response.urls && response.urls.length) {
|
|
if (response.urls && response.urls.length) {
|
|
@@ -91,18 +96,20 @@ async function saveUrls(urls, options = {}) {
|
|
|
await initMaxParallelWorkers();
|
|
await initMaxParallelWorkers();
|
|
|
await Promise.all(urls.map(async url => {
|
|
await Promise.all(urls.map(async url => {
|
|
|
const tabOptions = await config.getOptions(url);
|
|
const tabOptions = await config.getOptions(url);
|
|
|
- Object.keys(options).forEach(key => tabOptions[key] = options[key]);
|
|
|
|
|
- tabOptions.autoClose = true;
|
|
|
|
|
- tabOptions.extensionScriptFiles = extensionScriptFiles;
|
|
|
|
|
- if (tabOptions.passReferrerOnError) {
|
|
|
|
|
- requests.enableReferrerOnError();
|
|
|
|
|
|
|
+ if (tabOptions.profileName != config.DISABLED_PROFILE_NAME) {
|
|
|
|
|
+ Object.keys(options).forEach(key => tabOptions[key] = options[key]);
|
|
|
|
|
+ tabOptions.autoClose = true;
|
|
|
|
|
+ tabOptions.extensionScriptFiles = extensionScriptFiles;
|
|
|
|
|
+ if (tabOptions.passReferrerOnError) {
|
|
|
|
|
+ requests.enableReferrerOnError();
|
|
|
|
|
+ }
|
|
|
|
|
+ addTask({
|
|
|
|
|
+ tab: { url },
|
|
|
|
|
+ status: TASK_PENDING_STATE,
|
|
|
|
|
+ options: tabOptions,
|
|
|
|
|
+ method: "content.save"
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|
|
|
- addTask({
|
|
|
|
|
- tab: { url },
|
|
|
|
|
- status: TASK_PENDING_STATE,
|
|
|
|
|
- options: tabOptions,
|
|
|
|
|
- method: "content.save"
|
|
|
|
|
- });
|
|
|
|
|
}));
|
|
}));
|
|
|
runTasks();
|
|
runTasks();
|
|
|
}
|
|
}
|
|
@@ -112,43 +119,52 @@ async function saveTabs(tabs, options = {}) {
|
|
|
await Promise.all(tabs.map(async tab => {
|
|
await Promise.all(tabs.map(async tab => {
|
|
|
const tabId = tab.id;
|
|
const tabId = tab.id;
|
|
|
const tabOptions = await config.getOptions(tab.url);
|
|
const tabOptions = await config.getOptions(tab.url);
|
|
|
- Object.keys(options).forEach(key => tabOptions[key] = options[key]);
|
|
|
|
|
- tabOptions.tabId = tabId;
|
|
|
|
|
- tabOptions.tabIndex = tab.index;
|
|
|
|
|
- tabOptions.extensionScriptFiles = extensionScriptFiles;
|
|
|
|
|
- if (tabOptions.passReferrerOnError) {
|
|
|
|
|
- requests.enableReferrerOnError();
|
|
|
|
|
- }
|
|
|
|
|
- const tabData = {
|
|
|
|
|
- id: tab.id,
|
|
|
|
|
- index: tab.index,
|
|
|
|
|
- url: tab.url,
|
|
|
|
|
- title: tab.title
|
|
|
|
|
- };
|
|
|
|
|
- if (options.autoSave) {
|
|
|
|
|
- if (autoSaveIsEnabled(tab)) {
|
|
|
|
|
- const taskInfo = addTask({
|
|
|
|
|
- status: TASK_PROCESSING_STATE,
|
|
|
|
|
- tab: tabData,
|
|
|
|
|
- options: tabOptions,
|
|
|
|
|
- method: "content.autosave"
|
|
|
|
|
- });
|
|
|
|
|
- runTask(taskInfo);
|
|
|
|
|
|
|
+ if (tabOptions.profileName != config.DISABLED_PROFILE_NAME) {
|
|
|
|
|
+ Object.keys(options).forEach(key => tabOptions[key] = options[key]);
|
|
|
|
|
+ tabOptions.tabId = tabId;
|
|
|
|
|
+ tabOptions.tabIndex = tab.index;
|
|
|
|
|
+ tabOptions.extensionScriptFiles = extensionScriptFiles;
|
|
|
|
|
+ if (tabOptions.passReferrerOnError) {
|
|
|
|
|
+ requests.enableReferrerOnError();
|
|
|
}
|
|
}
|
|
|
- } else {
|
|
|
|
|
- ui.onStart(tabId, INJECT_SCRIPTS_STEP);
|
|
|
|
|
- const scriptsInjected = await injectScript(tabId, tabOptions);
|
|
|
|
|
- if (scriptsInjected || editor.isEditor(tab)) {
|
|
|
|
|
- ui.onStart(tabId, EXECUTE_SCRIPTS_STEP);
|
|
|
|
|
- addTask({
|
|
|
|
|
- status: TASK_PENDING_STATE,
|
|
|
|
|
- tab: tabData,
|
|
|
|
|
- options: tabOptions,
|
|
|
|
|
- method: "content.save"
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ const tabData = {
|
|
|
|
|
+ id: tab.id,
|
|
|
|
|
+ index: tab.index,
|
|
|
|
|
+ url: tab.url,
|
|
|
|
|
+ title: tab.title
|
|
|
|
|
+ };
|
|
|
|
|
+ if (options.autoSave) {
|
|
|
|
|
+ if (autoSaveIsEnabled(tab)) {
|
|
|
|
|
+ const taskInfo = addTask({
|
|
|
|
|
+ status: TASK_PROCESSING_STATE,
|
|
|
|
|
+ tab: tabData,
|
|
|
|
|
+ options: tabOptions,
|
|
|
|
|
+ method: "content.autosave"
|
|
|
|
|
+ });
|
|
|
|
|
+ runTask(taskInfo);
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
- ui.onForbiddenDomain(tab);
|
|
|
|
|
|
|
+ ui.onStart(tabId, INJECT_SCRIPTS_STEP);
|
|
|
|
|
+ let scriptsInjected;
|
|
|
|
|
+ try {
|
|
|
|
|
+ scriptsInjected = await injectScript(tabId, tabOptions);
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ // ignored
|
|
|
|
|
+ }
|
|
|
|
|
+ if (scriptsInjected || editor.isEditor(tab)) {
|
|
|
|
|
+ ui.onStart(tabId, EXECUTE_SCRIPTS_STEP);
|
|
|
|
|
+ addTask({
|
|
|
|
|
+ status: TASK_PENDING_STATE,
|
|
|
|
|
+ tab: tabData,
|
|
|
|
|
+ options: tabOptions,
|
|
|
|
|
+ method: "content.save"
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ui.onForbiddenDomain(tab);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+ } else {
|
|
|
|
|
+ ui.onForbiddenDomain(tab);
|
|
|
}
|
|
}
|
|
|
}));
|
|
}));
|
|
|
runTasks();
|
|
runTasks();
|
|
@@ -208,7 +224,11 @@ async function runTask(taskInfo) {
|
|
|
taskInfo.tab.id = taskInfo.options.tabId = tab.id;
|
|
taskInfo.tab.id = taskInfo.options.tabId = tab.id;
|
|
|
taskInfo.tab.index = taskInfo.options.tabIndex = tab.index;
|
|
taskInfo.tab.index = taskInfo.options.tabIndex = tab.index;
|
|
|
ui.onStart(taskInfo.tab.id, INJECT_SCRIPTS_STEP);
|
|
ui.onStart(taskInfo.tab.id, INJECT_SCRIPTS_STEP);
|
|
|
- scriptsInjected = await injectScript(taskInfo.tab.id, taskInfo.options);
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ scriptsInjected = await injectScript(taskInfo.tab.id, taskInfo.options);
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ // ignored
|
|
|
|
|
+ }
|
|
|
} catch (tabId) {
|
|
} catch (tabId) {
|
|
|
taskInfo.tab.id = tabId;
|
|
taskInfo.tab.id = tabId;
|
|
|
}
|
|
}
|