parent
58c7955c64
commit
04b8a981ef
@ -549,6 +549,26 @@
|
||||
"description": "Preferences/General",
|
||||
"message": "Add new downloads paused, instead of starting them immediately"
|
||||
},
|
||||
"pref_button_type": {
|
||||
"description": "label",
|
||||
"message": "DownThemAll! button:"
|
||||
},
|
||||
"pref_button_type_dta": {
|
||||
"description": "label",
|
||||
"message": "DownThemAll! selection"
|
||||
},
|
||||
"pref_button_type_manager": {
|
||||
"description": "label",
|
||||
"message": "Open Manager"
|
||||
},
|
||||
"pref_button_type_popup": {
|
||||
"description": "label",
|
||||
"message": "Popup menu"
|
||||
},
|
||||
"pref_button_type_turbo": {
|
||||
"description": "label",
|
||||
"message": "OneClick!"
|
||||
},
|
||||
"pref_concurrent_downloads": {
|
||||
"description": "Preferences/Network",
|
||||
"message": "Concurrent downloads"
|
||||
@ -557,10 +577,6 @@
|
||||
"description": "Preferences/General",
|
||||
"message": "Show a notification when the queue finishes downloading"
|
||||
},
|
||||
"pref_global_turbo": {
|
||||
"description": "Preferences/General",
|
||||
"message": "Browser button should be OneClick!"
|
||||
},
|
||||
"pref_hide_context": {
|
||||
"description": "Preferences/General",
|
||||
"message": "Do not show general context menu items"
|
||||
|
@ -1,5 +1,5 @@
|
||||
{
|
||||
"global-turbo": false,
|
||||
"button-type": "popup",
|
||||
"concurrent": 4,
|
||||
"queue-notification": true,
|
||||
"finish-notification": true,
|
||||
|
@ -136,35 +136,6 @@ class Handler {
|
||||
}
|
||||
|
||||
locale.then(() => {
|
||||
new class Action extends Handler {
|
||||
constructor() {
|
||||
super();
|
||||
this.onClicked = this.onClicked.bind(this);
|
||||
action.onClicked.addListener(this.onClicked);
|
||||
}
|
||||
|
||||
async onClicked(tab: {id: number}) {
|
||||
if (!tab.id) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await this.processResults(
|
||||
true,
|
||||
await runContentJob(
|
||||
tab, "/bundles/content-gather.js", {
|
||||
type: "DTA:gather",
|
||||
selectionOnly: false,
|
||||
textLinks: await Prefs.get("text-links", true),
|
||||
schemes: Array.from(ALLOWED_SCHEMES.values()),
|
||||
transferable: TRANSFERABLE_PROPERTIES,
|
||||
}));
|
||||
}
|
||||
catch (ex) {
|
||||
console.error(ex);
|
||||
}
|
||||
}
|
||||
}();
|
||||
|
||||
const menuHandler = new class Menus extends Handler {
|
||||
constructor() {
|
||||
super();
|
||||
@ -421,7 +392,7 @@ locale.then(() => {
|
||||
}
|
||||
}
|
||||
|
||||
async enumulate(action: string) {
|
||||
async emulate(action: string) {
|
||||
const tab = await tabs.query({
|
||||
active: true,
|
||||
currentWindow: true,
|
||||
@ -543,34 +514,88 @@ locale.then(() => {
|
||||
}
|
||||
}();
|
||||
|
||||
Bus.on("do-regular", () => menuHandler.enumulate("DTARegular"));
|
||||
Bus.on("do-regular-all", () => menuHandler.enumulate("DTARegularAll"));
|
||||
Bus.on("do-turbo", () => menuHandler.enumulate("DTATurbo"));
|
||||
Bus.on("do-turbo-all", () => menuHandler.enumulate("DTATurboAll"));
|
||||
new class Action extends Handler {
|
||||
constructor() {
|
||||
super();
|
||||
this.onClicked = this.onClicked.bind(this);
|
||||
action.onClicked.addListener(this.onClicked);
|
||||
Prefs.get("button-type", false).then(v => this.adjust(v));
|
||||
Prefs.on("button-type", (prefs, key, value) => {
|
||||
this.adjust(value);
|
||||
});
|
||||
}
|
||||
|
||||
adjust(type: string) {
|
||||
action.setPopup({
|
||||
popup: type !== "popup" ? "" : "/windows/popup.html"
|
||||
});
|
||||
let icons;
|
||||
switch (type) {
|
||||
case "popup":
|
||||
icons = {
|
||||
16: "/style/icon16.png",
|
||||
32: "/style/icon32.png",
|
||||
48: "/style/icon48.png",
|
||||
64: "/style/icon64.png",
|
||||
96: "/style/icon96.png",
|
||||
128: "/style/icon128.png",
|
||||
256: "/style/icon256.png"
|
||||
};
|
||||
break;
|
||||
|
||||
case "dta":
|
||||
icons = {
|
||||
16: "/style/button-regular.png",
|
||||
32: "/style/button-regular@2x.png",
|
||||
};
|
||||
break;
|
||||
|
||||
case "turbo":
|
||||
icons = {
|
||||
16: "/style/button-turbo.png",
|
||||
32: "/style/button-turbo@2x.png",
|
||||
};
|
||||
break;
|
||||
|
||||
case "manager":
|
||||
icons = {
|
||||
16: "/style/button-manager.png",
|
||||
32: "/style/button-manager@2x.png",
|
||||
};
|
||||
break;
|
||||
}
|
||||
action.setIcon({path: icons});
|
||||
}
|
||||
|
||||
async onClicked() {
|
||||
switch (await Prefs.get("button-type")) {
|
||||
case "popup":
|
||||
break;
|
||||
|
||||
case "dta":
|
||||
menuHandler.emulate("DTARegular");
|
||||
break;
|
||||
|
||||
case "turbo":
|
||||
menuHandler.emulate("DTATurbo");
|
||||
break;
|
||||
|
||||
case "manager":
|
||||
menuHandler.emulate("DTAManager");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}();
|
||||
|
||||
|
||||
Bus.on("do-regular", () => menuHandler.emulate("DTARegular"));
|
||||
Bus.on("do-regular-all", () => menuHandler.emulate("DTARegularAll"));
|
||||
Bus.on("do-turbo", () => menuHandler.emulate("DTATurbo"));
|
||||
Bus.on("do-turbo-all", () => menuHandler.emulate("DTATurboAll"));
|
||||
Bus.on("do-single", () => API.singleRegular(null));
|
||||
Bus.on("open-manager", () => openManager(true));
|
||||
Bus.on("open-prefs", () => openPrefs());
|
||||
|
||||
function adjustAction(globalTurbo: boolean) {
|
||||
action.setPopup({
|
||||
popup: globalTurbo ? "" : "/windows/popup.html"
|
||||
});
|
||||
action.setIcon({
|
||||
path: globalTurbo ? {
|
||||
16: "/style/button-turbo.png",
|
||||
32: "/style/button-turbo@2x.png",
|
||||
} : {
|
||||
16: "/style/icon16.png",
|
||||
32: "/style/icon32.png",
|
||||
48: "/style/icon48.png",
|
||||
64: "/style/icon64.png",
|
||||
96: "/style/icon96.png",
|
||||
128: "/style/icon128.png",
|
||||
256: "/style/icon256.png"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
(async function init() {
|
||||
const urlBase = runtime.getURL("");
|
||||
history.onVisited.addListener(({url}: {url: string}) => {
|
||||
@ -610,10 +635,6 @@ locale.then(() => {
|
||||
}
|
||||
|
||||
await Prefs.set("last-run", new Date());
|
||||
Prefs.get("global-turbo", false).then(v => adjustAction(v));
|
||||
Prefs.on("global-turbo", (prefs, key, value) => {
|
||||
adjustAction(value);
|
||||
});
|
||||
await filters();
|
||||
await getManager();
|
||||
})().catch(ex => {
|
||||
|
@ -43,7 +43,14 @@
|
||||
<article id="tab-general" class="tab">
|
||||
<fieldset>
|
||||
<legend data-i18n="pref.ui">UI</legend>
|
||||
<label><input type="checkbox" id="pref-global-turbo"> <span data-i18n="pref-global-turbo">Global turbo</span></label>
|
||||
<div id="pref-button-type">
|
||||
<label data-i18n="pref-button-type"></label>
|
||||
<label><input type="radio" name="pref-button-type" value="popup"> <span data-i18n="pref-button-type-popup"></span></label>
|
||||
<label><input type="radio" name="pref-button-type" value="dta"> <span data-i18n="pref-button-type-dta"></span></label>
|
||||
<label><input type="radio" name="pref-button-type" value="turbo"> <span data-i18n="pref-button-type-turbo"></span></label>
|
||||
<label><input type="radio" name="pref-button-type" value="manager"> <span data-i18n="pref-button-type-manager"></span></label>
|
||||
</div>
|
||||
<hr>
|
||||
<label><input type="checkbox" id="pref-finish-notification"> <span data-i18n="pref-finish-notification"></span></label>
|
||||
<label><input type="checkbox" id="pref-sounds"> <span data-i18n="pref-sounds"></span></label>
|
||||
<label><input type="checkbox" id="pref-hide-context"> <span data-i18n="pref-hide-context"></span></label>
|
||||
|
@ -554,7 +554,6 @@ addEventListener("DOMContentLoaded", async () => {
|
||||
await localize(document.documentElement);
|
||||
|
||||
// General
|
||||
new BoolPref("pref-global-turbo", "global-turbo");
|
||||
new BoolPref("pref-queue-notification", "queue-notification");
|
||||
new BoolPref("pref-finish-notification", "finish-notification");
|
||||
new BoolPref("pref-sounds", "sounds");
|
||||
@ -565,6 +564,7 @@ addEventListener("DOMContentLoaded", async () => {
|
||||
new BoolPref("pref-add-paused", "add-paused");
|
||||
new BoolPref("pref-show-urls", "show-urls");
|
||||
new BoolPref("pref-remove-missing-on-init", "remove-missing-on-init");
|
||||
new OptionPref("pref-button-type", "button-type");
|
||||
new OptionPref("pref-conflict-action", "conflict-action");
|
||||
|
||||
$("#reset-confirmations").addEventListener("click", async () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user