From 94fe6736270c9139fc058ac3e7e96f4d1298ae52 Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Thu, 4 Jan 2024 18:50:38 +0100 Subject: [PATCH 01/14] [General] Fix broken links in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b5aa147..d4dc77c4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ![Chrome Web Store Users](https://img.shields.io/chrome-web-store/users/modofbhnhlagjmejdbalnijgncppjeio?style=for-the-badge&label=users&logo=google&logoColor=white) [![Mozilla Add-on](https://img.shields.io/amo/users/down-right-now?style=for-the-badge&label=users&logo=mozilla&logoColor=white)](https://addons.mozilla.org/firefox/addon/down-right-now/ "Mozilla Firefox Add-on") -[![Chocolatey](https://img.shields.io/chocolatey/dt/downzemall?style=for-the-badge&label=chocolatey%20package)](https://community.chocolatey.org/packages/downzemall) +[![Chocolatey](https://img.shields.io/chocolatey/dt/arrowdl?style=for-the-badge&label=chocolatey%20package)](https://community.chocolatey.org/packages/arrowdl) ![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/ArrowDLApp?style=for-the-badge&logo=x&label=Follow&logoColor=white) From 025a72e5127daf12f2721fbae7f0abf873a09662 Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Thu, 4 Jan 2024 19:21:18 +0100 Subject: [PATCH 02/14] [WebExtension] Rename DownRightNow to ArrowDL --- README.md | 4 ++-- docs/_posts/2019-12-05-web-extension.md | 12 +++++------- docs/category/download-advanced.md | 8 ++++---- docs/category/download.md | 16 ++++++++-------- docs/category/tutorial.md | 4 ++-- docs/index.md | 2 +- web-extension/extension/make.py | 4 ++-- .../src/base/_locales/ar/messages.json | 2 +- .../src/base/_locales/de/messages.json | 2 +- .../src/base/_locales/en/messages.json | 2 +- .../src/base/_locales/es/messages.json | 2 +- .../src/base/_locales/fr/messages.json | 2 +- .../src/base/_locales/hu/messages.json | 2 +- .../src/base/_locales/it/messages.json | 2 +- .../src/base/_locales/ja/messages.json | 2 +- .../src/base/_locales/ko/messages.json | 2 +- .../src/base/_locales/nl/messages.json | 2 +- .../src/base/_locales/pl/messages.json | 2 +- .../src/base/_locales/pt_BR/messages.json | 2 +- .../src/base/_locales/pt_PT/messages.json | 2 +- .../src/base/_locales/ru/messages.json | 2 +- .../src/base/_locales/vi/messages.json | 2 +- .../extension/src/chromium/background.js | 2 +- .../extension/src/chromium/options.js | 4 ++-- web-extension/extension/src/chromium/popup.js | 2 +- .../extension/src/firefox/background.js | 2 +- .../extension/src/firefox/manifest.json | 2 +- web-extension/extension/src/firefox/options.js | 4 ++-- web-extension/extension/src/firefox/popup.js | 2 +- .../macx/launcher-manifest-chrome.json | 4 ++-- .../macx/launcher-manifest-firefox.json | 4 ++-- .../unix/launcher-manifest-chrome.json | 4 ++-- .../unix/launcher-manifest-firefox.json | 4 ++-- .../windows/launcher-manifest-chrome.json | 4 ++-- .../windows/launcher-manifest-firefox.json | 4 ++-- web-extension/setup/macx/TODO | 2 +- web-extension/setup/unix/install.sh | 4 ++-- web-extension/setup/unix/uninstall.sh | 4 ++-- web-extension/setup/windows/install.bat | 18 +++++++++--------- web-extension/setup/windows/uninstall.bat | 10 +++++----- 40 files changed, 79 insertions(+), 81 deletions(-) diff --git a/README.md b/README.md index d4dc77c4..eb15f812 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ![GitHub All Releases](https://img.shields.io/github/downloads/setvisible/ArrowDL/total?style=for-the-badge) ![Chrome Web Store Users](https://img.shields.io/chrome-web-store/users/modofbhnhlagjmejdbalnijgncppjeio?style=for-the-badge&label=users&logo=google&logoColor=white) -[![Mozilla Add-on](https://img.shields.io/amo/users/down-right-now?style=for-the-badge&label=users&logo=mozilla&logoColor=white)](https://addons.mozilla.org/firefox/addon/down-right-now/ "Mozilla Firefox Add-on") +[![Mozilla Add-on](https://img.shields.io/amo/users/arrow-dl?style=for-the-badge&label=users&logo=mozilla&logoColor=white)](https://addons.mozilla.org/firefox/addon/arrow-dl/ "Mozilla Firefox Add-on") [![Chocolatey](https://img.shields.io/chocolatey/dt/arrowdl?style=for-the-badge&label=chocolatey%20package)](https://community.chocolatey.org/packages/arrowdl) ![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/ArrowDLApp?style=for-the-badge&logo=x&label=Follow&logoColor=white) @@ -66,7 +66,7 @@ More screenshots on the [Gallery](https://www.arrow-dl.com/ArrowDL/category/scre Go to [Download](https://www.arrow-dl.com/ArrowDL/category/download.html) page to install the application for your operating system. -Rem: *Native-Client* is an alternative to *DownRightNow*. Click [here](NativeClient.md "NativeClient.md") for more information. +Rem: *Native-Client* is an alternative to *ArrowDL*. Click [here](NativeClient.md "NativeClient.md") for more information. On Windows, you can also use the [Chocolatey package](https://community.chocolatey.org/packages/arrowdl) to handle the installation/updates: ```powershell diff --git a/docs/_posts/2019-12-05-web-extension.md b/docs/_posts/2019-12-05-web-extension.md index 547b297a..88ad0801 100644 --- a/docs/_posts/2019-12-05-web-extension.md +++ b/docs/_posts/2019-12-05-web-extension.md @@ -17,20 +17,18 @@ excerpt_separator: *ArrowDL* is now compatible with Chrome and Firefox! -The add-on *DownRightNow* sends data from your web browser to the standalone application *ArrowDL*. +The *ArrowDL* add-on sends data from your web browser to the *ArrowDL* application. ### Install the Web Browser Add-on (WebExtensions) | ![logo](/ArrowDL/assets/images/firefox.png) | ![logo](/ArrowDL/assets/images/chrome.png) | |-----------------------------------|----------------------------------| -| Click here to intall [DownRightNow for Mozilla Firefox](https://addons.mozilla.org/en-US/firefox/addon/down-right-now/ "https://addons.mozilla.org/en-US/firefox/addon/down-right-now/") | Click here to intall [DownRightNow for Google Chrome](https://chrome.google.com/webstore/detail/down-right-now/modofbhnhlagjmejdbalnijgncppjeio "https://chrome.google.com/webstore/detail/down-right-now/modofbhnhlagjmejdbalnijgncppjeio") | +| Click here to intall [ArrowDL for Mozilla Firefox](https://addons.mozilla.org/en-US/firefox/addon/arrow-dl/ "https://addons.mozilla.org/en-US/firefox/addon/arrow-dl/") | Click here to intall [ArrowDL for Google Chrome](https://chrome.google.com/webstore/detail/arrow-dl/modofbhnhlagjmejdbalnijgncppjeio "https://chrome.google.com/webstore/detail/arrow-dl/modofbhnhlagjmejdbalnijgncppjeio") | -1. Install **DownRightNow** add-on - -2. Go to the install directory of the Application (*ArrowDL*), and follow the instructions in `ReadMe.txt` - -3. Then, go to "*Options*" in the WebExtension interface in your Web Browser. It should tell you if it's correctly connected with the Application. +1. Install **ArrowDL** add-on +2. Go to the install directory of the application (*ArrowDL*), and follow the instructions in `ReadMe.txt` +3. Then, go to "*Options*" in the WebExtensions interface in your web browser. It should tell you if it's correctly connected with the application. diff --git a/docs/category/download-advanced.md b/docs/category/download-advanced.md index 4f3c807f..c7a45ce1 100644 --- a/docs/category/download-advanced.md +++ b/docs/category/download-advanced.md @@ -30,7 +30,7 @@ Table of Content: 2. Then, install the web extension: - 1. Install **DownRightNow** add-on on the [web browser](#install-webextension) + 1. Install **ArrowDL** add-on on the [web browser](#install-webextension) 2. Go to the install directory of the Application (*ArrowDL*), and follow the instructions in `ReadMe.txt` @@ -44,7 +44,7 @@ Choose the browser: | ![logo](/ArrowDL/assets/images/firefox.png) | ![logo](/ArrowDL/assets/images/chrome.png) | ![logo](/ArrowDL/assets/images/iexplorer.png) | |-----------------------------------|----------------------------------|----------------------------------| -| Click here to intall [DownRightNow for Mozilla Firefox](https://addons.mozilla.org/en-US/firefox/addon/down-right-now/ ) | Click here to intall [DownRightNow for Google Chrome](https://chrome.google.com/webstore/detail/down-right-now/modofbhnhlagjmejdbalnijgncppjeio "https://chrome.google.com/webstore/detail/down-right-now/modofbhnhlagjmejdbalnijgncppjeio") | Click here to intall... Just kidding | +| Click here to intall [ArrowDL for Mozilla Firefox](https://addons.mozilla.org/en-US/firefox/addon/arrow-dl/ ) | Click here to intall [ArrowDL for Google Chrome](https://chrome.google.com/webstore/detail/arrow-dl/modofbhnhlagjmejdbalnijgncppjeio "https://chrome.google.com/webstore/detail/arrow-dl/modofbhnhlagjmejdbalnijgncppjeio") | Click here to intall... Just kidding | #### Portable Archives @@ -153,8 +153,8 @@ Footnotes: /* A-Z sorted Urls */ const artifact_id_to_filenames = { - 'id_chromium': "DownRightNow_chromium_" + tag_name + ".zip", - 'id_firefox': "DownRightNow_firefox_" + tag_name + ".xpi", + 'id_chromium': "ArrowDL_chromium_" + tag_name + ".zip", + 'id_firefox': "ArrowDL_firefox_" + tag_name + ".xpi", 'id_linux_x64_app': "ArrowDL_" + tag_name + "_x86_64_no_launcher.AppImage", 'id_linux_x64_zip': "ArrowDL_" + tag_name + "_x86_64.tar.gz", 'id_mac_x64_dmg': "ArrowDL_" + tag_name + "_x86_64.dmg", diff --git a/docs/category/download.md b/docs/category/download.md index 71da9ff1..c47f682b 100644 --- a/docs/category/download.md +++ b/docs/category/download.md @@ -43,12 +43,12 @@ title: Download - + firefox logo - + chrome logo @@ -59,14 +59,14 @@ title: Download Click here to intall - - DownRightNow for Mozilla Firefox + + ArrowDL for Mozilla Firefox Click here to intall - - DownRightNow for Google Chrome + + ArrowDL for Google Chrome @@ -213,13 +213,13 @@ CPU architecture, browser, or release version, have a look at if (browserType === "Chrome") { webExtensionBrowserName = "Google Chrome"; - webExtensionUrl="https://chrome.google.com/webstore/detail/down-right-now/modofbhnhlagjmejdbalnijgncppjeio"; + webExtensionUrl="https://chrome.google.com/webstore/detail/arrow-dl/modofbhnhlagjmejdbalnijgncppjeio"; webExtensionImageSrc = "/ArrowDL/assets/images/chrome.png"; showSpecificInstructions(true); } else if (browserType === "Firefox") { webExtensionBrowserName = "Mozilla Firefox"; - webExtensionUrl="https://addons.mozilla.org/en-US/firefox/addon/down-right-now/"; + webExtensionUrl="https://addons.mozilla.org/en-US/firefox/addon/arrow-dl/"; webExtensionImageSrc = "/ArrowDL/assets/images/firefox.png"; showSpecificInstructions(true); diff --git a/docs/category/tutorial.md b/docs/category/tutorial.md index 5d70f1c8..24b97f61 100644 --- a/docs/category/tutorial.md +++ b/docs/category/tutorial.md @@ -10,11 +10,11 @@ It contains some dummy data to run the application. 1. Open *ArrowDL* - *Start Menu* > *ArrowDL* - > Or alternatively, open *DownRightNow* from your web browser (-> toolbar menu, or right-click context menu) + > Or alternatively, open *ArrowDL* add-on from your web browser (-> toolbar menu, or right-click context menu) 2. Open the wizard - copy-paste the URL - > Or alternatively, click 'immediate download' from *DownRightNow* + > Or alternatively, click 'immediate download' from *ArrowDL* add-on ![](../assets/images/tutorial/01-wizard.png) diff --git a/docs/index.md b/docs/index.md index 72f9f949..9e2e5f02 100644 --- a/docs/index.md +++ b/docs/index.md @@ -7,7 +7,7 @@ title: What is ArrowDL Based on the [Qt5](https://www.qt.io/ "https://www.qt.io/") framework, ArrowDL is written in C/C++. It's a free (as in "*free speech*" and also as in "*free beer*") software. Its use is governed by [LGPL](/ArrowDL/LICENSE.txt "LICENSE") License. -**DownRightNow is an add-on for Chrome/Firefox**. It connects *ArrowDL* with your web browser. This extension helps you to download all the links and media you can find on the Web. When you visit a page, click to DownRightNow to see the content of the page. The content are links, references, images, videos... and other media present on the page. +**ArrowDL add-on for Chrome/Firefox**. It connects *ArrowDL* with your web browser. This WebExtensions add-on helps you to download all the links and media you can find on the Web. When you visit a page, click to ArrowDL to see the content of the page. The content are links, references, images, videos... and other media present on the page. ![Screenshot](/ArrowDL/assets/images/screenshot_1280x800.png) diff --git a/web-extension/extension/make.py b/web-extension/extension/make.py index 4b92c2e7..6d91b01e 100644 --- a/web-extension/extension/make.py +++ b/web-extension/extension/make.py @@ -65,11 +65,11 @@ def make_addons(current_path, output_path): apply_version(application_version, os.path.join(output_path, "firefox", "manifest.json")) print("Archiving...") - base_name = f"DownRightNow_chromium_v{application_version}" + base_name = f"ArrowDL_chromium_v{application_version}" chromium_full_name = make_archive(base_name=base_name, format="zip", root_dir=os.path.join(output_path, "chromium"), base_dir=".") print(f"Created archive: {chromium_full_name}") - base_name = f"DownRightNow_firefox_v{application_version}" + base_name = f"ArrowDL_firefox_v{application_version}" name = make_archive(base_name=base_name, format="zip", root_dir=os.path.join(output_path, "firefox"), base_dir=".") firefox_full_name = name.replace(".zip", ".xpi") if os.path.exists(firefox_full_name): diff --git a/web-extension/extension/src/base/_locales/ar/messages.json b/web-extension/extension/src/base/_locales/ar/messages.json index a3827e9d..2ea6d075 100644 --- a/web-extension/extension/src/base/_locales/ar/messages.json +++ b/web-extension/extension/src/base/_locales/ar/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/base/_locales/de/messages.json b/web-extension/extension/src/base/_locales/de/messages.json index a3827e9d..2ea6d075 100644 --- a/web-extension/extension/src/base/_locales/de/messages.json +++ b/web-extension/extension/src/base/_locales/de/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/base/_locales/en/messages.json b/web-extension/extension/src/base/_locales/en/messages.json index a3827e9d..2ea6d075 100644 --- a/web-extension/extension/src/base/_locales/en/messages.json +++ b/web-extension/extension/src/base/_locales/en/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/base/_locales/es/messages.json b/web-extension/extension/src/base/_locales/es/messages.json index e8753e60..1e2656e0 100644 --- a/web-extension/extension/src/base/_locales/es/messages.json +++ b/web-extension/extension/src/base/_locales/es/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/base/_locales/fr/messages.json b/web-extension/extension/src/base/_locales/fr/messages.json index 8f4f8d82..f7396aeb 100644 --- a/web-extension/extension/src/base/_locales/fr/messages.json +++ b/web-extension/extension/src/base/_locales/fr/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/base/_locales/hu/messages.json b/web-extension/extension/src/base/_locales/hu/messages.json index eac0db4a..aa52d006 100644 --- a/web-extension/extension/src/base/_locales/hu/messages.json +++ b/web-extension/extension/src/base/_locales/hu/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/base/_locales/it/messages.json b/web-extension/extension/src/base/_locales/it/messages.json index ae95fddd..722c2bb7 100644 --- a/web-extension/extension/src/base/_locales/it/messages.json +++ b/web-extension/extension/src/base/_locales/it/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/base/_locales/ja/messages.json b/web-extension/extension/src/base/_locales/ja/messages.json index a3827e9d..2ea6d075 100644 --- a/web-extension/extension/src/base/_locales/ja/messages.json +++ b/web-extension/extension/src/base/_locales/ja/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/base/_locales/ko/messages.json b/web-extension/extension/src/base/_locales/ko/messages.json index a3827e9d..2ea6d075 100644 --- a/web-extension/extension/src/base/_locales/ko/messages.json +++ b/web-extension/extension/src/base/_locales/ko/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/base/_locales/nl/messages.json b/web-extension/extension/src/base/_locales/nl/messages.json index a37ea11f..6df4964a 100644 --- a/web-extension/extension/src/base/_locales/nl/messages.json +++ b/web-extension/extension/src/base/_locales/nl/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/base/_locales/pl/messages.json b/web-extension/extension/src/base/_locales/pl/messages.json index a3827e9d..2ea6d075 100644 --- a/web-extension/extension/src/base/_locales/pl/messages.json +++ b/web-extension/extension/src/base/_locales/pl/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/base/_locales/pt_BR/messages.json b/web-extension/extension/src/base/_locales/pt_BR/messages.json index 4c7ddef9..5a026143 100644 --- a/web-extension/extension/src/base/_locales/pt_BR/messages.json +++ b/web-extension/extension/src/base/_locales/pt_BR/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/base/_locales/pt_PT/messages.json b/web-extension/extension/src/base/_locales/pt_PT/messages.json index a3827e9d..2ea6d075 100644 --- a/web-extension/extension/src/base/_locales/pt_PT/messages.json +++ b/web-extension/extension/src/base/_locales/pt_PT/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/base/_locales/ru/messages.json b/web-extension/extension/src/base/_locales/ru/messages.json index a3827e9d..2ea6d075 100644 --- a/web-extension/extension/src/base/_locales/ru/messages.json +++ b/web-extension/extension/src/base/_locales/ru/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/base/_locales/vi/messages.json b/web-extension/extension/src/base/_locales/vi/messages.json index a3827e9d..2ea6d075 100644 --- a/web-extension/extension/src/base/_locales/vi/messages.json +++ b/web-extension/extension/src/base/_locales/vi/messages.json @@ -1,6 +1,6 @@ { "extensionName": { - "message": "Down Right Now", + "message": "ArrowDL", "description": "Name of the extension, displayed in the web store. Should not exceed 45 characters." }, "extensionDescription": { diff --git a/web-extension/extension/src/chromium/background.js b/web-extension/extension/src/chromium/background.js index c3f5fa41..6d145081 100644 --- a/web-extension/extension/src/chromium/background.js +++ b/web-extension/extension/src/chromium/background.js @@ -1,6 +1,6 @@ "use strict"; -const application = "com.setvisible.downrightnow"; +const application = "com.setvisible.arrowdl"; /* ***************************** */ /* Context Menu */ diff --git a/web-extension/extension/src/chromium/options.js b/web-extension/extension/src/chromium/options.js index fed94cff..cbd2d093 100644 --- a/web-extension/extension/src/chromium/options.js +++ b/web-extension/extension/src/chromium/options.js @@ -1,7 +1,7 @@ "use strict"; -const application = "com.setvisible.downrightnow"; -const website_download_link = "https://www.arrow-dl.com/ArrowDL/category/download.html"; +const application = "com.setvisible.arrowdl"; +const website_download_link = "https://www.arrow-dl.com/"; /* ***************************** */ /* Options */ diff --git a/web-extension/extension/src/chromium/popup.js b/web-extension/extension/src/chromium/popup.js index ac5f3190..94661a0d 100644 --- a/web-extension/extension/src/chromium/popup.js +++ b/web-extension/extension/src/chromium/popup.js @@ -1,6 +1,6 @@ "use strict"; -const application = "com.setvisible.downrightnow"; +const application = "com.setvisible.arrowdl"; /* ***************************** */ /* Native Message */ diff --git a/web-extension/extension/src/firefox/background.js b/web-extension/extension/src/firefox/background.js index bda1b7df..f59cbc3d 100644 --- a/web-extension/extension/src/firefox/background.js +++ b/web-extension/extension/src/firefox/background.js @@ -1,6 +1,6 @@ "use strict"; -const application = "DownRightNow"; +const application = "ArrowDL"; /* ***************************** */ /* Context Menu */ diff --git a/web-extension/extension/src/firefox/manifest.json b/web-extension/extension/src/firefox/manifest.json index 0e966507..0fa9e230 100644 --- a/web-extension/extension/src/firefox/manifest.json +++ b/web-extension/extension/src/firefox/manifest.json @@ -23,7 +23,7 @@ }, "default_locale": "en", "description": "__MSG_extensionDescription__", - "homepage_url": "https://www.arrow-dl.com/ArrowDL", + "homepage_url": "https://www.arrow-dl.com/", "icons": { "16": "icons/icon16.png", "24": "icons/icon24.png", diff --git a/web-extension/extension/src/firefox/options.js b/web-extension/extension/src/firefox/options.js index 93e431ae..2188509a 100644 --- a/web-extension/extension/src/firefox/options.js +++ b/web-extension/extension/src/firefox/options.js @@ -1,7 +1,7 @@ "use strict"; -const application = "DownRightNow"; -const website_download_link = "https://www.arrow-dl.com/ArrowDL/category/download.html"; +const application = "ArrowDL"; +const website_download_link = "https://www.arrow-dl.com/"; /* ***************************** */ /* Options */ diff --git a/web-extension/extension/src/firefox/popup.js b/web-extension/extension/src/firefox/popup.js index 8b91e9c6..17dcdd51 100644 --- a/web-extension/extension/src/firefox/popup.js +++ b/web-extension/extension/src/firefox/popup.js @@ -1,6 +1,6 @@ "use strict"; -const application = "DownRightNow"; +const application = "ArrowDL"; /* ***************************** */ /* Native Message */ diff --git a/web-extension/launcher/macx/launcher-manifest-chrome.json b/web-extension/launcher/macx/launcher-manifest-chrome.json index 82d288ed..4b419971 100644 --- a/web-extension/launcher/macx/launcher-manifest-chrome.json +++ b/web-extension/launcher/macx/launcher-manifest-chrome.json @@ -1,6 +1,6 @@ { - "name": "com.setvisible.downrightnow", - "description": "DownRightNow Launcher Host for Native Messaging", + "name": "com.setvisible.arrowdl", + "description": "ArrowDL Launcher Host for Native Messaging", "path": "/ABSOLUTE/PATH/TO/APP/DIRECTORY/launcher", "type": "stdio", "allowed_origins": [ "chrome-extension://modofbhnhlagjmejdbalnijgncppjeio/" ] diff --git a/web-extension/launcher/macx/launcher-manifest-firefox.json b/web-extension/launcher/macx/launcher-manifest-firefox.json index 3221fb2a..31e3d3b4 100644 --- a/web-extension/launcher/macx/launcher-manifest-firefox.json +++ b/web-extension/launcher/macx/launcher-manifest-firefox.json @@ -1,6 +1,6 @@ { - "name": "DownRightNow", - "description": "DownRightNow Launcher Host for Native Messaging", + "name": "ArrowDL", + "description": "ArrowDL Launcher Host for Native Messaging", "path": "/ABSOLUTE/PATH/TO/APP/DIRECTORY/launcher", "type": "stdio", "allowed_extensions": [ "DownRightNow@example.org" ] diff --git a/web-extension/launcher/unix/launcher-manifest-chrome.json b/web-extension/launcher/unix/launcher-manifest-chrome.json index 82d288ed..4b419971 100644 --- a/web-extension/launcher/unix/launcher-manifest-chrome.json +++ b/web-extension/launcher/unix/launcher-manifest-chrome.json @@ -1,6 +1,6 @@ { - "name": "com.setvisible.downrightnow", - "description": "DownRightNow Launcher Host for Native Messaging", + "name": "com.setvisible.arrowdl", + "description": "ArrowDL Launcher Host for Native Messaging", "path": "/ABSOLUTE/PATH/TO/APP/DIRECTORY/launcher", "type": "stdio", "allowed_origins": [ "chrome-extension://modofbhnhlagjmejdbalnijgncppjeio/" ] diff --git a/web-extension/launcher/unix/launcher-manifest-firefox.json b/web-extension/launcher/unix/launcher-manifest-firefox.json index 3221fb2a..31e3d3b4 100644 --- a/web-extension/launcher/unix/launcher-manifest-firefox.json +++ b/web-extension/launcher/unix/launcher-manifest-firefox.json @@ -1,6 +1,6 @@ { - "name": "DownRightNow", - "description": "DownRightNow Launcher Host for Native Messaging", + "name": "ArrowDL", + "description": "ArrowDL Launcher Host for Native Messaging", "path": "/ABSOLUTE/PATH/TO/APP/DIRECTORY/launcher", "type": "stdio", "allowed_extensions": [ "DownRightNow@example.org" ] diff --git a/web-extension/launcher/windows/launcher-manifest-chrome.json b/web-extension/launcher/windows/launcher-manifest-chrome.json index 4b9820df..666f7cf0 100644 --- a/web-extension/launcher/windows/launcher-manifest-chrome.json +++ b/web-extension/launcher/windows/launcher-manifest-chrome.json @@ -1,6 +1,6 @@ { - "name": "com.setvisible.downrightnow", - "description": "DownRightNow Launcher Host for Native Messaging", + "name": "com.setvisible.arrowdl", + "description": "ArrowDL Launcher Host for Native Messaging", "path": "launcher.exe", "type": "stdio", "allowed_origins": [ "chrome-extension://modofbhnhlagjmejdbalnijgncppjeio/" ] diff --git a/web-extension/launcher/windows/launcher-manifest-firefox.json b/web-extension/launcher/windows/launcher-manifest-firefox.json index d467a10c..fc8c4c29 100644 --- a/web-extension/launcher/windows/launcher-manifest-firefox.json +++ b/web-extension/launcher/windows/launcher-manifest-firefox.json @@ -1,6 +1,6 @@ { - "name": "DownRightNow", - "description": "DownRightNow Launcher Host for Native Messaging", + "name": "ArrowDL", + "description": "ArrowDL Launcher Host for Native Messaging", "path": "launcher.exe", "type": "stdio", "allowed_extensions": [ "DownRightNow@example.org" ] diff --git a/web-extension/setup/macx/TODO b/web-extension/setup/macx/TODO index e79f8548..902b7eb3 100644 --- a/web-extension/setup/macx/TODO +++ b/web-extension/setup/macx/TODO @@ -1,5 +1,5 @@ TODO copy to -~/Library/Application Support/Mozilla/NativeMessagingHosts/DownRightNow.json +~/Library/Application Support/Mozilla/NativeMessagingHosts/ArrowDL.json diff --git a/web-extension/setup/unix/install.sh b/web-extension/setup/unix/install.sh index 719d2f40..d4863019 100644 --- a/web-extension/setup/unix/install.sh +++ b/web-extension/setup/unix/install.sh @@ -30,12 +30,12 @@ install_manifest () { TITLE='Mozilla' SOURCE=./launcher-manifest-firefox.json DESTINATION=~/.mozilla/native-messaging-hosts -TARGET_NAME="DownRightNow" +TARGET_NAME="ArrowDL" install_manifest $TITLE $SOURCE $DESTINATION $TARGET_NAME TITLE='Chromium' SOURCE=./launcher-manifest-chrome.json DESTINATION=~/.config/chromium/NativeMessagingHosts/ -TARGET_NAME="com.setvisible.downrightnow" +TARGET_NAME="com.setvisible.arrowdl" install_manifest $TITLE $SOURCE $DESTINATION $TARGET_NAME diff --git a/web-extension/setup/unix/uninstall.sh b/web-extension/setup/unix/uninstall.sh index b73f7c24..dea3f333 100644 --- a/web-extension/setup/unix/uninstall.sh +++ b/web-extension/setup/unix/uninstall.sh @@ -20,12 +20,12 @@ uninstall_manifest () { TITLE='Mozilla' SOURCE=./launcher-manifest-firefox.json DESTINATION=~/.mozilla/native-messaging-hosts -TARGET_NAME="DownRightNow" +TARGET_NAME="ArrowDL" uninstall_manifest $TITLE $SOURCE $DESTINATION $TARGET_NAME TITLE='Chromium' SOURCE=./launcher-manifest-chrome.json DESTINATION=~/.config/chromium/NativeMessagingHosts/ -TARGET_NAME="com.setvisible.downrightnow" +TARGET_NAME="com.setvisible.arrowdl" uninstall_manifest $TITLE $SOURCE $DESTINATION $TARGET_NAME diff --git a/web-extension/setup/windows/install.bat b/web-extension/setup/windows/install.bat index 47d1bb52..445e3f44 100644 --- a/web-extension/setup/windows/install.bat +++ b/web-extension/setup/windows/install.bat @@ -22,7 +22,7 @@ IF NOT "%1"=="" ( ) ECHO ************************************************* -ECHO Down Right Now +ECHO ArrowDL ECHO ************************************************* ECHO. ECHO Install to: %INSTALL_PATH% @@ -31,26 +31,26 @@ ECHO. ECHO. ECHO Writting to Chrome Registry... ECHO --------------------------------- -ECHO Key: HKCU\Software\Google\Chrome\NativeMessagingHosts\com.setvisible.downrightnow -REG ADD "HKCU\Software\Google\Chrome\NativeMessagingHosts\com.setvisible.downrightnow" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-chrome.json" /f +ECHO Key: HKCU\Software\Google\Chrome\NativeMessagingHosts\com.setvisible.arrowdl +REG ADD "HKCU\Software\Google\Chrome\NativeMessagingHosts\com.setvisible.arrowdl" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-chrome.json" /f ECHO. ECHO Writting to Firefox Registry... ECHO --------------------------------- -ECHO Key: HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\DownRightNow -REG ADD "HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\DownRightNow" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-firefox.json" /f +ECHO Key: HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\ArrowDL +REG ADD "HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\ArrowDL" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-firefox.json" /f ECHO. ECHO Writting to Waterfox Registry... ECHO --------------------------------- -ECHO Key: HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\DownRightNow -REG ADD "HKCU\SOFTWARE\Waterfox\NativeMessagingHosts\DownRightNow" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-firefox.json" /f +ECHO Key: HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\ArrowDL +REG ADD "HKCU\SOFTWARE\Waterfox\NativeMessagingHosts\ArrowDL" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-firefox.json" /f ECHO. ECHO Writting to Thunderbird Registry... ECHO --------------------------------- -ECHO Key: HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\DownRightNow -REG ADD "HKCU\SOFTWARE\Thunderbird\NativeMessagingHosts\DownRightNow" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-firefox.json" /f +ECHO Key: HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\ArrowDL +REG ADD "HKCU\SOFTWARE\Thunderbird\NativeMessagingHosts\ArrowDL" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-firefox.json" /f ECHO. ECHO ^>^>^> Done! ^<^<^< diff --git a/web-extension/setup/windows/uninstall.bat b/web-extension/setup/windows/uninstall.bat index e35d536d..3a376bcb 100644 --- a/web-extension/setup/windows/uninstall.bat +++ b/web-extension/setup/windows/uninstall.bat @@ -15,29 +15,29 @@ IF NOT "%1"=="" ( ) ECHO ************************************************* -ECHO Down Right Now +ECHO ArrowDL ECHO ************************************************* ECHO. ECHO. ECHO Deleting Chrome Registry... ECHO --------------------------------- -REG DELETE "HKCU\Software\Google\Chrome\NativeMessagingHosts\com.setvisible.downrightnow" /f +REG DELETE "HKCU\Software\Google\Chrome\NativeMessagingHosts\com.setvisible.arrowdl" /f ECHO. ECHO Deleting Firefox Registry... ECHO --------------------------------- -REG DELETE "HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\DownRightNow" /f +REG DELETE "HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\ArrowDL" /f ECHO. ECHO Deleting Waterfox Registry... ECHO --------------------------------- -REG DELETE "HKCU\SOFTWARE\Waterfox\NativeMessagingHosts\DownRightNow" /f +REG DELETE "HKCU\SOFTWARE\Waterfox\NativeMessagingHosts\ArrowDL" /f ECHO. ECHO Deleting Thunderbird Registry... ECHO --------------------------------- -REG DELETE "HKCU\SOFTWARE\Thunderbird\NativeMessagingHosts\DownRightNow" /f +REG DELETE "HKCU\SOFTWARE\Thunderbird\NativeMessagingHosts\ArrowDL" /f ECHO. ECHO ^>^>^> Done! ^<^<^< From b35d8e3000443d93880ae2ffc2b65b6fa3c0ccec Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Thu, 4 Jan 2024 19:20:35 +0100 Subject: [PATCH 03/14] [Doc] Fix Qt5 mentions --- CONTRIBUTING.md | 44 +++++-------------- README.md | 2 +- TRANSLATORS.md | 6 +-- TROUBLESHOOTING.md | 2 + docs/_posts/2019-11-16-introducing-arrowdl.md | 2 +- docs/_posts/2019-12-05-web-extension.md | 2 +- docs/_posts/2020-08-12-proxy-settings.md | 2 +- docs/index.md | 2 +- 8 files changed, 22 insertions(+), 40 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index db1bc88e..61dbac1a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,9 +9,9 @@ Compiler default is C++11 (eventually C99 for C parts) Here's the software you'll need before you start building (mandatory in bold) - **Standard C++ Library** (>= C++11) -- **Qt5** (>= 5.5) -- **Boost** (>= 1.79) -- CMake (>= 3.1.0) or QMake (>= 5.5) +- **Qt6** (>= 6.0) +- **Boost** (>= 1.77) +- CMake (>= 3.1.0) - GNU C++ Compiler (gcc/g++ >= 5.3.0) or Microsoft Visual Studio (>= 2017) @@ -35,47 +35,34 @@ Follow official instructions of each tool. sudo apt install git sudo apt install git-gui -#### Install Qt5 - - sudo apt install qt5-default - whereis qt5 - $ qt5: /usr/lib/x86_64-linux-gnu/qt5 /usr/lib/qt5 /usr/share/qt5 - -#### Install Qt5 IDE (QtCreator) and SDK - - sudo apt install qtcreator - -Or follow [instructions](https://wiki.qt.io/Install_Qt_5_on_Ubuntu -"https://wiki.qt.io/Install_Qt_5_on_Ubuntu"). +#### Install Qt and QtCreator sudo apt install libfontconfig1 sudo apt install mesa-common-dev sudo apt install libglu1-mesa-dev - wget https://download.qt.io/official_releases/qt/5.14/5.14.2/qt-opensource-linux-x64-5.14.2.run + wget https://download.qt.io/official_releases/qt/6.0/6.0.0/qt-opensource-linux-x64-6.0.0.run - chmod +x qt-opensource-linux-x64-5.14.2.run - sudo ./qt-opensource-linux-x64-5.14.2.run + chmod +x qt-opensource-linux-x64-6.0.0.run + sudo ./qt-opensource-linux-x64-6.0.0.run -Select a dummy proxy, to skip the login page. - -It install the tools (QtCreator 4.11.1) and SDK on `/opt/Qt5.14.2/`. +It install the tools (QtCreator) and SDK on `/opt/Qt/`. Run it: - /opt/Qt5.14.2/Tools/QtCreator/bin/qtcreator + /opt/Qt/Tools/QtCreator/bin/qtcreator Create a shortcut (Ubuntu, KDE...): mkdir ~/.local/share/applications - cp /opt/Qt5.14.2/Tools/QtCreator/share/applications/org.qt-project.qtcreator.desktop ~/.local/share/applications + cp /opt/Qt/Tools/QtCreator/share/applications/org.qt-project.qtcreator.desktop ~/.local/share/applications #### Install Boost C++ Library - wget https://boostorg.jfrog.io/artifactory/main/release/1.79.0/source/boost_1_79_0.tar.bz2 - tar -zxvf boost_1_79_0.tar.gz + wget https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.bz2 + tar -zxvf boost_1_77_0.tar.gz Or download and unzip manually an older version of [Boost](https://www.boost.org/users/history/). @@ -96,13 +83,6 @@ Setup the *Boost* library: - For CMake: Add variable `BOOST_ROOT_DIR` (type: PATH) with the path to Boost PS: or configure `Boost_INCLUDE_DIR` - -- For QMake: - Open `./3rd/boost/boost.pri` - and add path manually to variable `BOOST_ROOT_DIR`, - that gives the following line: - `BOOST_ROOT_DIR = /Boost/boost_1_79_0` - Build the application: diff --git a/README.md b/README.md index eb15f812..e1812a44 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,6 @@ Click [here](CONTRIBUTING.md "CONTRIBUTING.md") for build instructions and tips. The code is released under the GNU [Lesser General Public License (LGPL)](LICENSE "LICENSE"). -Use it at your own risk. None of the authors, contributors, or anyone else connected with this ArrowDL software and the DownRightNow web-extension, in any way whatsoever, can be responsible for your use of the application. +Use it at your own risk. None of the authors, contributors, or anyone else connected with this ArrowDL software and the ArrowDL add-ons, in any way whatsoever, can be responsible for your use of the application. Please be aware that this site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. diff --git a/TRANSLATORS.md b/TRANSLATORS.md index 4b9ec7f3..c5843449 100644 --- a/TRANSLATORS.md +++ b/TRANSLATORS.md @@ -104,7 +104,7 @@ Note that unfinished translations may also be deployed from time to time. ### Offline Translation This method requires: -- [Qt Framework](https://www.qt.io/) (Qt5.14 at the time of writing these lines) +- [Qt Framework](https://www.qt.io/) - local clone of the repository These files are the translations source (*.ts): @@ -189,7 +189,7 @@ It generates *.qm (compiled translation files) to be deployed with the applicati ## References -- [Internationalization with Qt](https://doc.qt.io/qt-5/internationalization.html) -- [Qt Linguist Manual](https://doc.qt.io/qt-5/qtlinguist-index.html) +- [Internationalization with Qt](https://doc.qt.io/qt-6/internationalization.html) +- [Qt Linguist Manual](https://doc.qt.io/qt-6/qtlinguist-index.html) - [Transifex Documentation](https://docs.transifex.com/formats/qt-ts) - [Transifex TX Client](https://docs.transifex.com/transifex-github-integrations/github-tx-client) diff --git a/TROUBLESHOOTING.md b/TROUBLESHOOTING.md index cb7d19b3..36f30405 100644 --- a/TROUBLESHOOTING.md +++ b/TROUBLESHOOTING.md @@ -1,5 +1,7 @@ # Troubleshooting +**This page is frozen. Please use Github > Issues instead.** + ## Security Restriction ### Binary signature diff --git a/docs/_posts/2019-11-16-introducing-arrowdl.md b/docs/_posts/2019-11-16-introducing-arrowdl.md index c142d230..632c98b5 100644 --- a/docs/_posts/2019-11-16-introducing-arrowdl.md +++ b/docs/_posts/2019-11-16-introducing-arrowdl.md @@ -14,7 +14,7 @@ excerpt_separator: It aims to work with latest versions of Mozilla Firefox (powered by *WebExtensions*), and other web browsers (Chrome, Edge, Safari...). -*ArrowDL* is written in C++ and based on the [Qt5](https://www.qt.io/ "https://www.qt.io/") framework. +*ArrowDL* is written in C++ and based on the [Qt](https://www.qt.io/ "https://www.qt.io/") framework. ## Goals diff --git a/docs/_posts/2019-12-05-web-extension.md b/docs/_posts/2019-12-05-web-extension.md index 88ad0801..105236be 100644 --- a/docs/_posts/2019-12-05-web-extension.md +++ b/docs/_posts/2019-12-05-web-extension.md @@ -20,7 +20,7 @@ excerpt_separator: The *ArrowDL* add-on sends data from your web browser to the *ArrowDL* application. -### Install the Web Browser Add-on (WebExtensions) +### Install the Add-on | ![logo](/ArrowDL/assets/images/firefox.png) | ![logo](/ArrowDL/assets/images/chrome.png) | |-----------------------------------|----------------------------------| diff --git a/docs/_posts/2020-08-12-proxy-settings.md b/docs/_posts/2020-08-12-proxy-settings.md index c55997cd..c97d9b32 100644 --- a/docs/_posts/2020-08-12-proxy-settings.md +++ b/docs/_posts/2020-08-12-proxy-settings.md @@ -62,7 +62,7 @@ LibTorrent uses a separate settings storage, then to enable proxying with torren ### Further reading - [Proxy server](https://en.wikipedia.org/wiki/Proxy_server) definition on Wikipedia -- Qt5 [Proxy Documentation](https://doc.qt.io/qt-5/qnetworkproxy.html) +- Qt6 [Proxy Documentation](https://doc.qt.io/qt-6/qnetworkproxy.html) - LibTorrent [Proxy Documentation](https://www.libtorrent.org/features.html) diff --git a/docs/index.md b/docs/index.md index 9e2e5f02..9ab24d91 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5,7 +5,7 @@ title: What is ArrowDL **ArrowDL is a mass download manager** for Windows, Mac OS X and Linux. It helps you to select, organize, prioritize and run your downloads in parallel. -Based on the [Qt5](https://www.qt.io/ "https://www.qt.io/") framework, ArrowDL is written in C/C++. It's a free (as in "*free speech*" and also as in "*free beer*") software. Its use is governed by [LGPL](/ArrowDL/LICENSE.txt "LICENSE") License. +Based on the [Qt](https://www.qt.io/ "https://www.qt.io/") framework, ArrowDL is written in C/C++. It's a free (as in "*free speech*" and also as in "*free beer*") software. Its use is governed by [LGPL](/ArrowDL/LICENSE.txt "LICENSE") License. **ArrowDL add-on for Chrome/Firefox**. It connects *ArrowDL* with your web browser. This WebExtensions add-on helps you to download all the links and media you can find on the Web. When you visit a page, click to ArrowDL to see the content of the page. The content are links, references, images, videos... and other media present on the page. From 29aff4b640559b3fc99708e534b8158223122ac4 Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Thu, 4 Jan 2024 18:54:30 +0100 Subject: [PATCH 04/14] [i18n] Update translations --- src/locale/arrowdl_it_IT.ts | 4 ++-- src/locale/arrowdl_nl_NL.ts | 4 ++-- src/locale/arrowdl_zh_CN.ts | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/locale/arrowdl_it_IT.ts b/src/locale/arrowdl_it_IT.ts index d1000e88..222421df 100644 --- a/src/locale/arrowdl_it_IT.ts +++ b/src/locale/arrowdl_it_IT.ts @@ -2875,12 +2875,12 @@ Per proteggere la privacy, inserisci un indirizzo Riferimento vuoto o falso. Bootstrap Icons (default) - + Icone bootstrap (predefinite) FontAwesome Flat Design - + Design piatto FontAwesome diff --git a/src/locale/arrowdl_nl_NL.ts b/src/locale/arrowdl_nl_NL.ts index fbea4b9e..69ca5d8f 100644 --- a/src/locale/arrowdl_nl_NL.ts +++ b/src/locale/arrowdl_nl_NL.ts @@ -2861,12 +2861,12 @@ Hieronder volgen enkele voorbeelden. Klik om het voorbeeld te plakken. Bootstrap Icons (default) - + Pictogrammen extraheren (standaard) FontAwesome Flat Design - + FontAwesome - Plat ontwerp diff --git a/src/locale/arrowdl_zh_CN.ts b/src/locale/arrowdl_zh_CN.ts index d993d0a4..f7a4343d 100644 --- a/src/locale/arrowdl_zh_CN.ts +++ b/src/locale/arrowdl_zh_CN.ts @@ -2251,12 +2251,12 @@ Some examples are given below. Click to paste the example. Concurrent fragments: - + 并发片段: 20 - + 20 @@ -2723,7 +2723,7 @@ Some examples are given below. Click to paste the example. Servers might split large files into multiple fragments, to optimize downloads. This option enables multi-threaded fragment downloads: Select the number of fragments that should be downloaded concurrently. Note that the concurrency makes download faster (when available), but the progress status and estimated time could be inaccurate (by design). Choose between precision and speed. Recommended value depends on your connection and machine. 20 is a good start. To disable it, set it to 1. - + 服务器可能会将大文件分割成多个片段,以优化下载。 此选项启用多线程片段下载:选择应同时下载的片段数量。 请注意,并发性使下载速度更快(如果可用),但进度状态和估计时间可能不准确(根据设计)。 在精度和速度之间进行选择。 建议值取决于您的连接和机器。 20 是一个好的开始。 要禁用它,请将其设置为 1。 @@ -2861,12 +2861,12 @@ Some examples are given below. Click to paste the example. Bootstrap Icons (default) - + Bootstrap 图标(默认) FontAwesome Flat Design - + FontAwesome 平面设计 From 18dd153fc5c1a9e1bc8afedbcf4aeacbaddfe4db Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Sun, 7 Jan 2024 12:02:29 +0100 Subject: [PATCH 05/14] [WebExtension] Replace old 'var' to 'const' or 'let' in javascript --- .../extension/src/chromium/background.js | 30 +++++------ .../extension/src/chromium/options.js | 46 ++++++++-------- web-extension/extension/src/chromium/popup.js | 22 ++++---- .../extension/src/firefox/background.js | 34 ++++++------ .../extension/src/firefox/options.js | 52 +++++++++---------- web-extension/extension/src/firefox/popup.js | 26 +++++----- 6 files changed, 101 insertions(+), 109 deletions(-) diff --git a/web-extension/extension/src/chromium/background.js b/web-extension/extension/src/chromium/background.js index 6d145081..e0a72c27 100644 --- a/web-extension/extension/src/chromium/background.js +++ b/web-extension/extension/src/chromium/background.js @@ -64,7 +64,7 @@ function save_image(info, tab) { /* ***************************** */ /* Options */ /* ***************************** */ -var mySettings = undefined; +let mySettings = undefined; function getDownloadActionChoice() { function onOptionResponse(response) { @@ -111,10 +111,10 @@ function isSettingStartPaused() { function collectDOMandSendData() { function myFunction(myArgument) { - var restoredSettings = myArgument; // not necessary: JSON.parse(myArgument); - var hasLinks = true; - var hasMedia = true; - var array = ""; + const restoredSettings = myArgument; // not necessary: JSON.parse(myArgument); + let hasLinks = true; + let hasMedia = true; + let array = ""; // Options if (restoredSettings.radioApplicationId === 1) { @@ -148,10 +148,8 @@ function collectDOMandSendData() { if (hasLinks) { // Get all elements of type array += "[LINKS] "; - var links = document.getElementsByTagName("a"); - var max = links.length; - var i = 0; - for (; i < max; i++) { + const links = document.getElementsByTagName("a"); + for (let i = 0; i < links.length; i++) { array += links[i].href; array += " "; } @@ -160,10 +158,8 @@ function collectDOMandSendData() { if (hasMedia) { // Get all elements of type array += "[MEDIA] "; - var pictures = document.getElementsByTagName("img"); - var max = pictures.length; - var i = 0; - for (; i < max; i++) { + const pictures = document.getElementsByTagName("img"); + for (let i = 0; i < pictures.length; i++) { array += pictures[i].src; array += " "; } @@ -172,7 +168,7 @@ function collectDOMandSendData() { return array; } - var myArgument = JSON.stringify(mySettings); + const myArgument = JSON.stringify(mySettings); // We have permission to access the activeTab, so we can call chrome.tabs.executeScript. /* Remark: @@ -181,7 +177,7 @@ function collectDOMandSendData() { * myFunction is interpreted as a string. * Indeed, "(" + myFunction + ")()" is a string, because function.toString() returns function's code. */ - var codeToExecute = "(" + myFunction + ")(" + myArgument + ");"; + const codeToExecute = "(" + myFunction + ")(" + myArgument + ");"; chrome.tabs.executeScript({ "code": codeToExecute @@ -196,7 +192,7 @@ function collectDOMandSendData() { function collectDOMandSendDataWithWizard() { // We *hack* the settings - var previous = mySettings.radioApplicationId; + const previous = mySettings.radioApplicationId; mySettings.radioApplicationId = 1; collectDOMandSendData(); @@ -235,7 +231,7 @@ function sendData(links) { console.log(`Error: ${error}`); } - var data = "launch " + links; + const data = "launch " + links; console.log("Sending message to launcher: " + data); chrome.runtime.sendNativeMessage(application, { "text": data }, onResponse); } diff --git a/web-extension/extension/src/chromium/options.js b/web-extension/extension/src/chromium/options.js index cbd2d093..ee9c9d8f 100644 --- a/web-extension/extension/src/chromium/options.js +++ b/web-extension/extension/src/chromium/options.js @@ -29,12 +29,12 @@ function restoreOptions() { } function saveOptions() { - var options = getOptions(); + const options = getOptions(); chrome.storage.local.set(options); } function getOptions() { - var options = {}; + const options = {}; options["radioApplicationId"] = getApplicationRadio(); options["radioMediaId"] = getMediaRadio(); options["startPaused"] = isStartPaused(); @@ -98,7 +98,7 @@ function setStartPaused(value) { } function refreshButtons(){ - var isChecked = document.getElementById("download_immediately").checked; + const isChecked = document.getElementById("download_immediately").checked; setDivEnabled("full_menu_label", isChecked); setButtonEnabled("get_links", isChecked); setButtonEnabled("get_content", isChecked); @@ -115,10 +115,10 @@ function setDivEnabled(name, enabled) { } function setButtonEnabled(name, enabled) { - var inputButton = document.getElementById(name); + const inputButton = document.getElementById(name); inputButton.disabled = !enabled; - for (var i = 0; i < inputButton.labels.length; i++) { - var label = inputButton.labels[i]; + for (let i = 0; i < inputButton.labels.length; i++) { + const label = inputButton.labels[i]; if (enabled) { label.classList.remove("disabled"); } else { @@ -128,12 +128,12 @@ function setButtonEnabled(name, enabled) { } function showOptions(visible) { - var instructions = document.getElementsByClassName("show-instruction"); - for (var i = 0; i < instructions.length; i ++) { + const instructions = document.getElementsByClassName("show-instruction"); + for (let i = 0; i < instructions.length; i ++) { instructions[i].style.display = visible ? "none" : "block"; } - var options = document.getElementsByClassName("options"); - for (var i = 0; i < options.length; i ++) { + const options = document.getElementsByClassName("options"); + for (let i = 0; i < options.length; i ++) { options[i].style.display = visible ? "block" : "none"; } } @@ -151,10 +151,10 @@ function checkConnection() { onHelloError(response); } else { console.log(`Message from the launcher: ${response.text}`); - var messageOk = chrome.i18n.getMessage("optionsOk"); - var messageDetectedPath = chrome.i18n.getMessage("optionsDetectedPath"); - var connectionStatus = "✓ " + messageOk; - var details = "

" + messageDetectedPath + "
" + response.text + ""; + const messageOk = chrome.i18n.getMessage("optionsOk"); + const messageDetectedPath = chrome.i18n.getMessage("optionsDetectedPath"); + const connectionStatus = "✓ " + messageOk; + const details = "

" + messageDetectedPath + "
" + response.text + ""; setConnectionStatus(connectionStatus, details, "MediumSeaGreen"); showOptions(true); } @@ -162,20 +162,20 @@ function checkConnection() { function onHelloError(error) { console.log(`Launcher didn't send any message. ${error}.`); - var messageError = chrome.i18n.getMessage("optionsError"); - var messageInstructions = chrome.i18n.getMessage("optionsInstructions"); - var connectionStatus = "⚠ " + messageError; - var details = "

" + messageInstructions; + const messageError = chrome.i18n.getMessage("optionsError"); + const messageInstructions = chrome.i18n.getMessage("optionsInstructions"); + const connectionStatus = "⚠ " + messageError; + const details = "

" + messageInstructions; setConnectionStatus(connectionStatus, details, "Tomato"); showOptions(false); } - var data = "areyouthere"; + const data = "areyouthere"; chrome.runtime.sendNativeMessage(application, { "text": data }, onHelloResponse); } function setConnectionStatus(connectionStatus, details, color) { - var messageStatus = chrome.i18n.getMessage("optionsStatus"); + const messageStatus = chrome.i18n.getMessage("optionsStatus"); const statusTag = `${messageStatus}  ${connectionStatus}    ${details}`; safeInnerHtmlAssignment2("status-message", statusTag); @@ -223,7 +223,7 @@ function notifyBackgroundPage() { function onError(error) { console.log(`Error: ${error}`); } - var options = getOptions(); + const options = getOptions(); chrome.runtime.sendMessage(options, onResponse); } @@ -234,8 +234,8 @@ function loadPage() { restoreOptions(); checkInstallation(); - var input = document.querySelectorAll("input"); - for(var i = 0; i < input.length; i++) { + const input = document.querySelectorAll("input"); + for (let i = 0; i < input.length; i++) { input[i].addEventListener("change", onInputChanged); } } diff --git a/web-extension/extension/src/chromium/popup.js b/web-extension/extension/src/chromium/popup.js index 94661a0d..feba8e1d 100644 --- a/web-extension/extension/src/chromium/popup.js +++ b/web-extension/extension/src/chromium/popup.js @@ -23,7 +23,7 @@ function checkConnection() { showWarningMessage(true); } - var data = "areyouthere"; + const data = "areyouthere"; chrome.runtime.sendNativeMessage(application, { "text": data }, onResponse); } @@ -32,7 +32,7 @@ function checkConnection() { /* Core */ /* ***************************** */ function showWarningMessage(hasError) { - var x = document.getElementById("warning-area"); + const x = document.getElementById("warning-area"); if (hasError) { x.style.display = "block"; } else { @@ -63,8 +63,8 @@ function setVisible(name, visible) { } function immediateButtonLabel() { - var mediaId = getBackgroundPage().getSettingMediaId(); - var startPaused = getBackgroundPage().isSettingStartPaused(); + const mediaId = getBackgroundPage().getSettingMediaId(); + const startPaused = getBackgroundPage().isSettingStartPaused(); if (mediaId === 1) { if (startPaused) { return chrome.i18n.getMessage("popupDownloadLinksPaused") @@ -109,7 +109,7 @@ function hasIncognitoModeBug() { } function showIncognitoWarningMessage(hasError) { - var x = document.getElementById("warning-area-incognito"); + const x = document.getElementById("warning-area-incognito"); if (hasError) { x.style.display = "block"; } else { @@ -165,7 +165,7 @@ class DummyChromeExtensionForIncognitoMode { console.log(`Error: ${error}`); } - var data = "launch " + links; + const data = "launch " + links; console.log("Sending message to launcher: " + data); chrome.runtime.sendNativeMessage(application, { "text": data }, onResponse); } @@ -178,11 +178,11 @@ function onLoaded() { checkConnection(); checkIncognitoMode(); - var enabled = getBackgroundPage().isSettingAskEnabled(); + const enabled = getBackgroundPage().isSettingAskEnabled(); setVisible("button-immediate-download", !enabled); if (!enabled) { - var label = immediateButtonLabel(); + const label = immediateButtonLabel(); safeInnerHtmlAssignment("button-immediate-download-label", label); } } @@ -200,19 +200,19 @@ document.getElementById("button-immediate-download").addEventListener('click', ( }); document.getElementById("button-manager").addEventListener('click', () => { - var command = "[MANAGER]"; + const command = "[MANAGER]"; getBackgroundPage().sendData(command); window.close(); }); document.getElementById("button-preference").addEventListener('click', () => { - var command = "[PREFS]"; + const command = "[PREFS]"; getBackgroundPage().sendData(command); window.close(); }); document.getElementById("button-options-page").addEventListener('click', () => { - var openingPage = chrome.runtime.openOptionsPage(); + const openingPage = chrome.runtime.openOptionsPage(); window.close(); }); diff --git a/web-extension/extension/src/firefox/background.js b/web-extension/extension/src/firefox/background.js index f59cbc3d..60b9dc84 100644 --- a/web-extension/extension/src/firefox/background.js +++ b/web-extension/extension/src/firefox/background.js @@ -62,7 +62,7 @@ function save_image(info, tab) { /* ***************************** */ /* Options */ /* ***************************** */ -var mySettings = undefined; +let mySettings = undefined; function getDownloadActionChoice() { function onOptionResponse(response) { @@ -72,7 +72,7 @@ function getDownloadActionChoice() { function onOptionError(error) { console.log(`Error: ${error}`); } - var getting = browser.storage.local.get(); + const getting = browser.storage.local.get(); getting.then(onOptionResponse, onOptionError); } @@ -102,10 +102,10 @@ function isSettingStartPaused() { function collectDOMandSendData() { function myFunction(myArgument) { - var restoredSettings = myArgument; // not necessary: JSON.parse(myArgument); - var hasLinks = true; - var hasMedia = true; - var array = ""; + const restoredSettings = myArgument; // not necessary: JSON.parse(myArgument); + let hasLinks = true; + let hasMedia = true; + let array = ""; // Options if (restoredSettings.radioApplicationId === 1) { @@ -139,10 +139,8 @@ function collectDOMandSendData() { if (hasLinks) { // Get all elements of type array += "[LINKS] "; - var links = document.getElementsByTagName("a"); - var max = links.length; - var i = 0; - for (; i < max; i++) { + const links = document.getElementsByTagName("a"); + for (let i = 0; i < links.length; i++) { array += links[i].href; array += " "; } @@ -151,10 +149,8 @@ function collectDOMandSendData() { if (hasMedia) { // Get all elements of type array += "[MEDIA] "; - var pictures = document.getElementsByTagName("img"); - var max = pictures.length; - var i = 0; - for (; i < max; i++) { + const pictures = document.getElementsByTagName("img"); + for (let i = 0; i < pictures.length; i++) { array += pictures[i].src; array += " "; } @@ -163,7 +159,7 @@ function collectDOMandSendData() { return array; } - var myArgument = JSON.stringify(mySettings); + const myArgument = JSON.stringify(mySettings); // We have permission to access the activeTab, so we can call browser.tabs.executeScript. /* Remark: @@ -172,7 +168,7 @@ function collectDOMandSendData() { * myFunction is interpreted as a string. * Indeed, "(" + myFunction + ")()" is a string, because function.toString() returns function's code. */ - var codeToExecute = "(" + myFunction + ")(" + myArgument + ");"; + const codeToExecute = "(" + myFunction + ")(" + myArgument + ");"; browser.tabs.executeScript({ "code": codeToExecute @@ -184,7 +180,7 @@ function collectDOMandSendData() { function collectDOMandSendDataWithWizard() { // We *hack* the settings - var previous = mySettings.radioApplicationId; + const previous = mySettings.radioApplicationId; mySettings.radioApplicationId = 1; collectDOMandSendData(); @@ -215,9 +211,9 @@ function sendData(links) { console.log(`Error: ${error}`); } - var data = "launch " + links; + const data = "launch " + links; console.log("Sending message to launcher: " + data); - var sending = browser.runtime.sendNativeMessage(application, data); + const sending = browser.runtime.sendNativeMessage(application, data); sending.then(onResponse, onError); } diff --git a/web-extension/extension/src/firefox/options.js b/web-extension/extension/src/firefox/options.js index 2188509a..c07dbadf 100644 --- a/web-extension/extension/src/firefox/options.js +++ b/web-extension/extension/src/firefox/options.js @@ -17,17 +17,17 @@ function restoreOptions() { console.log(`Error: ${error}`); } - var getting = browser.storage.local.get(); + const getting = browser.storage.local.get(); getting.then(onOptionResponse, onOptionError); } function saveOptions() { - var options = getOptions(); + const options = getOptions(); browser.storage.local.set(options); } function getOptions() { - var options = {}; + const options = {}; options["radioApplicationId"] = getApplicationRadio(); options["radioMediaId"] = getMediaRadio(); options["startPaused"] = isStartPaused(); @@ -91,7 +91,7 @@ function setStartPaused(value) { } function refreshButtons(){ - var isChecked = document.getElementById("download_immediately").checked; + const isChecked = document.getElementById("download_immediately").checked; setDivEnabled("full_menu_label", isChecked); setButtonEnabled("get_links", isChecked); setButtonEnabled("get_content", isChecked); @@ -108,10 +108,10 @@ function setDivEnabled(name, enabled) { } function setButtonEnabled(name, enabled) { - var inputButton = document.getElementById(name); + const inputButton = document.getElementById(name); inputButton.disabled = !enabled; - for (var i = 0; i < inputButton.labels.length; i++) { - var label = inputButton.labels[i]; + for (let i = 0; i < inputButton.labels.length; i++) { + const label = inputButton.labels[i]; if (enabled) { label.classList.remove("disabled"); } else { @@ -121,12 +121,12 @@ function setButtonEnabled(name, enabled) { } function showOptions(visible) { - var instructions = document.getElementsByClassName("show-instruction"); - for (var i = 0; i < instructions.length; i ++) { + const instructions = document.getElementsByClassName("show-instruction"); + for (let i = 0; i < instructions.length; i ++) { instructions[i].style.display = visible ? "none" : "block"; } - var options = document.getElementsByClassName("options"); - for (var i = 0; i < options.length; i ++) { + const options = document.getElementsByClassName("options"); + for (let i = 0; i < options.length; i ++) { options[i].style.display = visible ? "block" : "none"; } } @@ -137,31 +137,31 @@ function showOptions(visible) { function checkConnection() { function onHelloResponse(response) { console.log(`Message from the launcher: ${response.text}`); - var messageOk = browser.i18n.getMessage("optionsOk"); - var messageDetectedPath = browser.i18n.getMessage("optionsDetectedPath"); - var connectionStatus = "✓ " + messageOk; - var details = "

" + messageDetectedPath + "
" + response.text + ""; + const messageOk = browser.i18n.getMessage("optionsOk"); + const messageDetectedPath = browser.i18n.getMessage("optionsDetectedPath"); + const connectionStatus = "✓ " + messageOk; + const details = "

" + messageDetectedPath + "
" + response.text + ""; setConnectionStatus(connectionStatus, details, "MediumSeaGreen"); showOptions(true); } function onHelloError(error) { console.log(`Launcher didn't send any message. ${error}.`); - var messageError = browser.i18n.getMessage("optionsError"); - var messageInstructions = browser.i18n.getMessage("optionsInstructions"); - var connectionStatus = "⚠ " + messageError; - var details = "

" + messageInstructions; + const messageError = browser.i18n.getMessage("optionsError"); + const messageInstructions = browser.i18n.getMessage("optionsInstructions"); + const connectionStatus = "⚠ " + messageError; + const details = "

" + messageInstructions; setConnectionStatus(connectionStatus, details, "Tomato"); showOptions(false); } - var data = "areyouthere"; - var sending = browser.runtime.sendNativeMessage(application, data); + const data = "areyouthere"; + const sending = browser.runtime.sendNativeMessage(application, data); sending.then(onHelloResponse, onHelloError); } function setConnectionStatus(connectionStatus, details, color) { - var messageStatus = browser.i18n.getMessage("optionsStatus"); + const messageStatus = browser.i18n.getMessage("optionsStatus"); const statusTag = `${messageStatus}  ${connectionStatus}    ${details}`; safeInnerHtmlAssignment2("status-message", statusTag); @@ -201,8 +201,8 @@ function notifyBackgroundPage() { function onError(error) { console.log(`Error: ${error}`); } - var options = getOptions(); - var sending = browser.runtime.sendMessage(options); + const options = getOptions(); + const sending = browser.runtime.sendMessage(options); sending.then(onResponse, onError); } @@ -213,8 +213,8 @@ function loadPage() { restoreOptions(); checkInstallation(); - var input = document.querySelectorAll("input"); - for(var i = 0; i < input.length; i++) { + const input = document.querySelectorAll("input"); + for (let i = 0; i < input.length; i++) { input[i].addEventListener("change", onInputChanged); } } diff --git a/web-extension/extension/src/firefox/popup.js b/web-extension/extension/src/firefox/popup.js index 17dcdd51..154b4b1c 100644 --- a/web-extension/extension/src/firefox/popup.js +++ b/web-extension/extension/src/firefox/popup.js @@ -13,8 +13,8 @@ function checkConnection() { function onError(error) { showWarningMessage(true); } - var data = "areyouthere"; - var sending = browser.runtime.sendNativeMessage(application, data); + const data = "areyouthere"; + const sending = browser.runtime.sendNativeMessage(application, data); sending.then(onResponse, onError); } @@ -23,7 +23,7 @@ function checkConnection() { /* Core */ /* ***************************** */ function showWarningMessage(hasError) { - var x = document.getElementById("warning-area"); + const x = document.getElementById("warning-area"); if (hasError) { x.style.display = "block"; } else { @@ -54,8 +54,8 @@ function setVisible(name, visible) { } function immediateButtonLabel() { - var mediaId = getBackgroundPage().getSettingMediaId(); - var startPaused = getBackgroundPage().isSettingStartPaused(); + const mediaId = getBackgroundPage().getSettingMediaId(); + const startPaused = getBackgroundPage().isSettingStartPaused(); if (mediaId === 1) { if (startPaused) { return browser.i18n.getMessage("popupDownloadLinksPaused") @@ -100,7 +100,7 @@ function hasIncognitoModeBug() { } function showIncognitoWarningMessage(hasError) { - var x = document.getElementById("warning-area-incognito"); + const x = document.getElementById("warning-area-incognito"); if (hasError) { x.style.display = "block"; } else { @@ -146,9 +146,9 @@ class DummyChromeExtensionForIncognitoMode { function onError(error) { console.log(`Error: ${error}`); } - var data = "launch " + links; + const data = "launch " + links; console.log("Sending message to launcher: " + data); - var sending = browser.runtime.sendNativeMessage(application, data); + const sending = browser.runtime.sendNativeMessage(application, data); sending.then(onResponse, onError); } } @@ -160,11 +160,11 @@ function onLoaded() { checkConnection(); checkIncognitoMode(); - var enabled = getBackgroundPage().isSettingAskEnabled(); + const enabled = getBackgroundPage().isSettingAskEnabled(); setVisible("button-immediate-download", !enabled); if (!enabled) { - var label = immediateButtonLabel(); + const label = immediateButtonLabel(); safeInnerHtmlAssignment("button-immediate-download-label", label); } } @@ -182,19 +182,19 @@ document.getElementById("button-immediate-download").addEventListener('click', ( }); document.getElementById("button-manager").addEventListener('click', () => { - var command = "[MANAGER]"; + const command = "[MANAGER]"; getBackgroundPage().sendData(command); window.close(); }); document.getElementById("button-preference").addEventListener('click', () => { - var command = "[PREFS]"; + const command = "[PREFS]"; getBackgroundPage().sendData(command); window.close(); }); document.getElementById("button-options-page").addEventListener('click', () => { - var openingPage = browser.runtime.openOptionsPage(); + const openingPage = browser.runtime.openOptionsPage(); window.close(); }); From ce0d747bbbb5b48bf63513db63e634b1a873ccf1 Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Sun, 7 Jan 2024 12:05:20 +0100 Subject: [PATCH 06/14] [WebExtension] Rename extension to ensure consistency across all browsers --- .../extension/src/chromium/background.js | 2 +- .../extension/src/chromium/manifest.json | 2 +- web-extension/extension/src/chromium/options.js | 2 +- web-extension/extension/src/chromium/popup.js | 2 +- .../extension/src/firefox/background.js | 2 +- web-extension/extension/src/firefox/options.js | 2 +- web-extension/extension/src/firefox/popup.js | 2 +- .../windows/launcher-manifest-chrome.json | 2 +- .../windows/launcher-manifest-firefox.json | 2 +- web-extension/setup/unix/install.sh | 4 ++-- web-extension/setup/unix/uninstall.sh | 4 ++-- web-extension/setup/windows/install.bat | 16 ++++++++-------- web-extension/setup/windows/uninstall.bat | 8 ++++---- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/web-extension/extension/src/chromium/background.js b/web-extension/extension/src/chromium/background.js index e0a72c27..0c69dffa 100644 --- a/web-extension/extension/src/chromium/background.js +++ b/web-extension/extension/src/chromium/background.js @@ -1,6 +1,6 @@ "use strict"; -const application = "com.setvisible.arrowdl"; +const application = "com.arrowdl.extension"; /* ***************************** */ /* Context Menu */ diff --git a/web-extension/extension/src/chromium/manifest.json b/web-extension/extension/src/chromium/manifest.json index 85c2c2dc..8fdad841 100644 --- a/web-extension/extension/src/chromium/manifest.json +++ b/web-extension/extension/src/chromium/manifest.json @@ -17,7 +17,7 @@ }, "default_locale": "en", "description": "__MSG_extensionDescription__", - "homepage_url": "https://www.arrow-dl.com/ArrowDL", + "homepage_url": "https://www.arrow-dl.com/", "icons": { "16": "icons/icon16.png", "24": "icons/icon24.png", diff --git a/web-extension/extension/src/chromium/options.js b/web-extension/extension/src/chromium/options.js index ee9c9d8f..715046f5 100644 --- a/web-extension/extension/src/chromium/options.js +++ b/web-extension/extension/src/chromium/options.js @@ -1,6 +1,6 @@ "use strict"; -const application = "com.setvisible.arrowdl"; +const application = "com.arrowdl.extension"; const website_download_link = "https://www.arrow-dl.com/"; /* ***************************** */ diff --git a/web-extension/extension/src/chromium/popup.js b/web-extension/extension/src/chromium/popup.js index feba8e1d..fbccfc4e 100644 --- a/web-extension/extension/src/chromium/popup.js +++ b/web-extension/extension/src/chromium/popup.js @@ -1,6 +1,6 @@ "use strict"; -const application = "com.setvisible.arrowdl"; +const application = "com.arrowdl.extension"; /* ***************************** */ /* Native Message */ diff --git a/web-extension/extension/src/firefox/background.js b/web-extension/extension/src/firefox/background.js index 60b9dc84..24ec85aa 100644 --- a/web-extension/extension/src/firefox/background.js +++ b/web-extension/extension/src/firefox/background.js @@ -1,6 +1,6 @@ "use strict"; -const application = "ArrowDL"; +const application = "com.arrowdl.extension"; /* ***************************** */ /* Context Menu */ diff --git a/web-extension/extension/src/firefox/options.js b/web-extension/extension/src/firefox/options.js index c07dbadf..22795aa3 100644 --- a/web-extension/extension/src/firefox/options.js +++ b/web-extension/extension/src/firefox/options.js @@ -1,6 +1,6 @@ "use strict"; -const application = "ArrowDL"; +const application = "com.arrowdl.extension"; const website_download_link = "https://www.arrow-dl.com/"; /* ***************************** */ diff --git a/web-extension/extension/src/firefox/popup.js b/web-extension/extension/src/firefox/popup.js index 154b4b1c..6f0f5d01 100644 --- a/web-extension/extension/src/firefox/popup.js +++ b/web-extension/extension/src/firefox/popup.js @@ -1,6 +1,6 @@ "use strict"; -const application = "ArrowDL"; +const application = "com.arrowdl.extension"; /* ***************************** */ /* Native Message */ diff --git a/web-extension/launcher/windows/launcher-manifest-chrome.json b/web-extension/launcher/windows/launcher-manifest-chrome.json index 666f7cf0..4a886a8f 100644 --- a/web-extension/launcher/windows/launcher-manifest-chrome.json +++ b/web-extension/launcher/windows/launcher-manifest-chrome.json @@ -1,5 +1,5 @@ { - "name": "com.setvisible.arrowdl", + "name": "com.arrowdl.extension", "description": "ArrowDL Launcher Host for Native Messaging", "path": "launcher.exe", "type": "stdio", diff --git a/web-extension/launcher/windows/launcher-manifest-firefox.json b/web-extension/launcher/windows/launcher-manifest-firefox.json index fc8c4c29..22e5a379 100644 --- a/web-extension/launcher/windows/launcher-manifest-firefox.json +++ b/web-extension/launcher/windows/launcher-manifest-firefox.json @@ -1,5 +1,5 @@ { - "name": "ArrowDL", + "name": "com.arrowdl.extension", "description": "ArrowDL Launcher Host for Native Messaging", "path": "launcher.exe", "type": "stdio", diff --git a/web-extension/setup/unix/install.sh b/web-extension/setup/unix/install.sh index d4863019..1bc49b32 100644 --- a/web-extension/setup/unix/install.sh +++ b/web-extension/setup/unix/install.sh @@ -30,12 +30,12 @@ install_manifest () { TITLE='Mozilla' SOURCE=./launcher-manifest-firefox.json DESTINATION=~/.mozilla/native-messaging-hosts -TARGET_NAME="ArrowDL" +TARGET_NAME="com.arrowdl.extension" install_manifest $TITLE $SOURCE $DESTINATION $TARGET_NAME TITLE='Chromium' SOURCE=./launcher-manifest-chrome.json DESTINATION=~/.config/chromium/NativeMessagingHosts/ -TARGET_NAME="com.setvisible.arrowdl" +TARGET_NAME="com.arrowdl.extension" install_manifest $TITLE $SOURCE $DESTINATION $TARGET_NAME diff --git a/web-extension/setup/unix/uninstall.sh b/web-extension/setup/unix/uninstall.sh index dea3f333..11091ea3 100644 --- a/web-extension/setup/unix/uninstall.sh +++ b/web-extension/setup/unix/uninstall.sh @@ -20,12 +20,12 @@ uninstall_manifest () { TITLE='Mozilla' SOURCE=./launcher-manifest-firefox.json DESTINATION=~/.mozilla/native-messaging-hosts -TARGET_NAME="ArrowDL" +TARGET_NAME="com.arrowdl.extension" uninstall_manifest $TITLE $SOURCE $DESTINATION $TARGET_NAME TITLE='Chromium' SOURCE=./launcher-manifest-chrome.json DESTINATION=~/.config/chromium/NativeMessagingHosts/ -TARGET_NAME="com.setvisible.arrowdl" +TARGET_NAME="com.arrowdl.extension" uninstall_manifest $TITLE $SOURCE $DESTINATION $TARGET_NAME diff --git a/web-extension/setup/windows/install.bat b/web-extension/setup/windows/install.bat index 445e3f44..e9094bba 100644 --- a/web-extension/setup/windows/install.bat +++ b/web-extension/setup/windows/install.bat @@ -31,26 +31,26 @@ ECHO. ECHO. ECHO Writting to Chrome Registry... ECHO --------------------------------- -ECHO Key: HKCU\Software\Google\Chrome\NativeMessagingHosts\com.setvisible.arrowdl -REG ADD "HKCU\Software\Google\Chrome\NativeMessagingHosts\com.setvisible.arrowdl" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-chrome.json" /f +ECHO Key: HKCU\Software\Google\Chrome\NativeMessagingHosts\com.arrowdl.extension +REG ADD "HKCU\Software\Google\Chrome\NativeMessagingHosts\com.arrowdl.extension" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-chrome.json" /f ECHO. ECHO Writting to Firefox Registry... ECHO --------------------------------- -ECHO Key: HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\ArrowDL -REG ADD "HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\ArrowDL" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-firefox.json" /f +ECHO Key: HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\com.arrowdl.extension +REG ADD "HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\com.arrowdl.extension" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-firefox.json" /f ECHO. ECHO Writting to Waterfox Registry... ECHO --------------------------------- -ECHO Key: HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\ArrowDL -REG ADD "HKCU\SOFTWARE\Waterfox\NativeMessagingHosts\ArrowDL" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-firefox.json" /f +ECHO Key: HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\com.arrowdl.extension +REG ADD "HKCU\SOFTWARE\Waterfox\NativeMessagingHosts\com.arrowdl.extension" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-firefox.json" /f ECHO. ECHO Writting to Thunderbird Registry... ECHO --------------------------------- -ECHO Key: HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\ArrowDL -REG ADD "HKCU\SOFTWARE\Thunderbird\NativeMessagingHosts\ArrowDL" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-firefox.json" /f +ECHO Key: HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\com.arrowdl.extension +REG ADD "HKCU\SOFTWARE\Thunderbird\NativeMessagingHosts\com.arrowdl.extension" /ve /t REG_SZ /d "%INSTALL_PATH%\launcher-manifest-firefox.json" /f ECHO. ECHO ^>^>^> Done! ^<^<^< diff --git a/web-extension/setup/windows/uninstall.bat b/web-extension/setup/windows/uninstall.bat index 3a376bcb..fca342f4 100644 --- a/web-extension/setup/windows/uninstall.bat +++ b/web-extension/setup/windows/uninstall.bat @@ -22,22 +22,22 @@ ECHO. ECHO. ECHO Deleting Chrome Registry... ECHO --------------------------------- -REG DELETE "HKCU\Software\Google\Chrome\NativeMessagingHosts\com.setvisible.arrowdl" /f +REG DELETE "HKCU\Software\Google\Chrome\NativeMessagingHosts\com.arrowdl.extension" /f ECHO. ECHO Deleting Firefox Registry... ECHO --------------------------------- -REG DELETE "HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\ArrowDL" /f +REG DELETE "HKCU\SOFTWARE\Mozilla\NativeMessagingHosts\com.arrowdl.extension" /f ECHO. ECHO Deleting Waterfox Registry... ECHO --------------------------------- -REG DELETE "HKCU\SOFTWARE\Waterfox\NativeMessagingHosts\ArrowDL" /f +REG DELETE "HKCU\SOFTWARE\Waterfox\NativeMessagingHosts\com.arrowdl.extension" /f ECHO. ECHO Deleting Thunderbird Registry... ECHO --------------------------------- -REG DELETE "HKCU\SOFTWARE\Thunderbird\NativeMessagingHosts\ArrowDL" /f +REG DELETE "HKCU\SOFTWARE\Thunderbird\NativeMessagingHosts\com.arrowdl.extension" /f ECHO. ECHO ^>^>^> Done! ^<^<^< From 63757c25775d4f042ad9f57d5b71f61496db2c75 Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Sun, 7 Jan 2024 12:12:06 +0100 Subject: [PATCH 07/14] [WebExtension] Rename extension short name --- web-extension/extension/src/chromium/manifest.json | 2 +- web-extension/extension/src/firefox/manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/web-extension/extension/src/chromium/manifest.json b/web-extension/extension/src/chromium/manifest.json index 8fdad841..1181a4e6 100644 --- a/web-extension/extension/src/chromium/manifest.json +++ b/web-extension/extension/src/chromium/manifest.json @@ -39,6 +39,6 @@ "storage", "tabs" ], - "short_name": "DRN!", + "short_name": "ArrowDL", "version": "0.0.65536" } diff --git a/web-extension/extension/src/firefox/manifest.json b/web-extension/extension/src/firefox/manifest.json index 0fa9e230..fbfa8662 100644 --- a/web-extension/extension/src/firefox/manifest.json +++ b/web-extension/extension/src/firefox/manifest.json @@ -47,6 +47,6 @@ "storage", "tabs" ], - "short_name": "DRN!", + "short_name": "ArrowDL", "version": "0.0.65536" } From c4c6c7d2a67ac2e9e81562bb39dd37218f432f67 Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Sun, 7 Jan 2024 12:10:37 +0100 Subject: [PATCH 08/14] [WebExtension] Fix warning "Only packaged apps are allowed to use 'launcher' context" --- web-extension/extension/src/chromium/background.js | 2 -- web-extension/extension/src/firefox/background.js | 2 -- 2 files changed, 4 deletions(-) diff --git a/web-extension/extension/src/chromium/background.js b/web-extension/extension/src/chromium/background.js index 0c69dffa..fac63265 100644 --- a/web-extension/extension/src/chromium/background.js +++ b/web-extension/extension/src/chromium/background.js @@ -28,7 +28,6 @@ chrome.contextMenus.removeAll( addAction("save-image", chrome.i18n.getMessage("contextMenuSaveImage"), "image"); addAction("save-video", chrome.i18n.getMessage("contextMenuSaveVideo"), "video"); addAction("save-audio", chrome.i18n.getMessage("contextMenuSaveAudio"), "audio"); - addAction("save-launcher", chrome.i18n.getMessage("contextMenuSaveLauncher"), "launcher"); } ); @@ -38,7 +37,6 @@ chrome.contextMenus.onClicked.addListener( } else if (info.menuItemId === "save-frame" ) { save_page(info, tab); } else if (info.menuItemId === "save-image" ) { save_image(info, tab); } else if (info.menuItemId === "save-audio" ) { save_image(info, tab); - } else if (info.menuItemId === "save-launcher" ) { save_page(info, tab); } else if (info.menuItemId === "save-link" ) { save_link(info, tab); } else if (info.menuItemId === "save-selection" ) { save_page(info, tab); } else if (info.menuItemId === "save-video" ) { save_image(info, tab); diff --git a/web-extension/extension/src/firefox/background.js b/web-extension/extension/src/firefox/background.js index 24ec85aa..08cc0f68 100644 --- a/web-extension/extension/src/firefox/background.js +++ b/web-extension/extension/src/firefox/background.js @@ -26,7 +26,6 @@ browser.contextMenus.removeAll( addAction("save-image", browser.i18n.getMessage("contextMenuSaveImage"), "image"); addAction("save-video", browser.i18n.getMessage("contextMenuSaveVideo"), "video"); addAction("save-audio", browser.i18n.getMessage("contextMenuSaveAudio"), "audio"); - addAction("save-launcher", browser.i18n.getMessage("contextMenuSaveLauncher"), "launcher"); } ); @@ -36,7 +35,6 @@ browser.contextMenus.onClicked.addListener( } else if (info.menuItemId === "save-frame" ) { save_page(info, tab); } else if (info.menuItemId === "save-image" ) { save_image(info, tab); } else if (info.menuItemId === "save-audio" ) { save_image(info, tab); - } else if (info.menuItemId === "save-launcher" ) { save_page(info, tab); } else if (info.menuItemId === "save-link" ) { save_link(info, tab); } else if (info.menuItemId === "save-selection" ) { save_page(info, tab); } else if (info.menuItemId === "save-video" ) { save_image(info, tab); From 3163ace9e08781641da19663d9e9380bcf91ec0b Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Sun, 7 Jan 2024 12:10:54 +0100 Subject: [PATCH 09/14] [WebExtension] Upgrade web-extension to manifest v3 --- web-extension/extension/README.md | 2 +- .../extension/src/chromium/background.js | 306 +++++++++--------- .../extension/src/chromium/manifest.json | 9 +- .../extension/src/chromium/options.js | 2 +- web-extension/extension/src/chromium/popup.js | 167 +++------- .../extension/src/firefox/background.js | 301 +++++++++-------- .../extension/src/firefox/manifest.json | 6 +- .../extension/src/firefox/options.js | 57 ++-- web-extension/extension/src/firefox/popup.js | 168 ++++------ 9 files changed, 471 insertions(+), 547 deletions(-) diff --git a/web-extension/extension/README.md b/web-extension/extension/README.md index 44039a16..dd8c54e3 100644 --- a/web-extension/extension/README.md +++ b/web-extension/extension/README.md @@ -23,4 +23,4 @@ eq. to: .\make.bat --output-directory . -See `.appveyor` script for packaging to .ZIP and .XPI files. +See the Github Workflows script for packaging to .ZIP and .XPI files. diff --git a/web-extension/extension/src/chromium/background.js b/web-extension/extension/src/chromium/background.js index fac63265..0cf1c93f 100644 --- a/web-extension/extension/src/chromium/background.js +++ b/web-extension/extension/src/chromium/background.js @@ -2,6 +2,9 @@ const application = "com.arrowdl.extension"; +// let us know we're running +console.log("Background service worker has loaded via Manifest V3."); + /* ***************************** */ /* Context Menu */ /* ***************************** */ @@ -46,192 +49,187 @@ chrome.contextMenus.onClicked.addListener( ); function save_page(info, tab) { - collectDOMandSendData(); + chrome.storage.local.get((userSettings) => { + collectDOMandSendData(userSettings); + }); } function save_link(info, tab) { - const safeUrl = escapeHTML(info.linkUrl); - sendData("[DOWNLOAD_LINK] " + safeUrl); + let safeUrl = escapeHTML(info.linkUrl); + sendDataToArrowDL("[DOWNLOAD_LINK] " + safeUrl); } function save_image(info, tab) { const safeUrl = escapeHTML(info.srcUrl); - sendData("[DOWNLOAD_LINK] " + safeUrl); + sendDataToArrowDL("[DOWNLOAD_LINK] " + safeUrl); } + /* ***************************** */ -/* Options */ +/* Collect links and media */ /* ***************************** */ -let mySettings = undefined; - -function getDownloadActionChoice() { - function onOptionResponse(response) { - if (chrome.runtime.lastError) { - console.log(chrome.runtime.lastError.message); - onOptionError(response); - } - if (response === undefined) { - onOptionError(response); - } else { - mySettings = response; - // console.log("Settings changed: " + JSON.stringify(mySettings)); - } - } - function onOptionError(error) { - console.log(`Error: ${error}`); - } - chrome.storage.local.get(onOptionResponse); -} - -getDownloadActionChoice(); - -function isSettingAskEnabled() { - return mySettings === undefined || mySettings.radioApplicationId === undefined || mySettings.radioApplicationId === 1; -} - -function getSettingMediaId() { - if (mySettings === undefined) { - return -1; - } - return mySettings.radioMediaId; -} - -function isSettingStartPaused() { - if (mySettings === undefined) { - return false; - } - return mySettings.startPaused; +function collectDOMandSendData(userSettings) { + + chrome.tabs.query({"active": true, "lastFocusedWindow": true}, (tabs) => { + + const tab = tabs[0]; + const tabId = tab.id; + const tabUrl = tab.url; + + if (tabUrl.startsWith("chrome")) { + console.log("Nothing to download from 'chrome://' or 'chrome-extension://'"); + console.log("ArrowDL is disabled when the current tab is Chrome settings tab."); + return; + } + + function injectableScriptFunction(args) { + const restoredSettings = JSON.parse(args); + let hasLinks = true; + let hasMedia = true; + let array = ""; + + console.log(restoredSettings); + + // Options + if (restoredSettings.radioApplicationId === 1) { + array += ""; + + } else if (restoredSettings.radioApplicationId === 2) { + + if (restoredSettings.radioMediaId === 1) { + hasMedia = false; + array += "[QUICK_LINKS]"; + array += " "; + + } else if (restoredSettings.radioMediaId === 2) { + hasLinks = false; + array += "[QUICK_MEDIA]"; + array += " "; + } + + if (restoredSettings.startPaused === true) { + array += "[STARTED_PAUSED]"; + array += " "; + } + } + + // Get the current URL + const url = document.URL; + array += "[CURRENT_URL] "; + array += url; + array += " "; + + if (hasLinks) { + // Get all elements of type + array += "[LINKS] "; + const links = document.getElementsByTagName("a"); + for (let i = 0; i < links.length; i++) { + array += links[i].href; + array += " "; + } + } + + if (hasMedia) { + // Get all elements of type + array += "[MEDIA] "; + const pictures = document.getElementsByTagName("img"); + for (let i = 0; i < pictures.length; i++) { + array += pictures[i].src; + array += " "; + } + } + + return array; + } + + /* Remark: + * code: "" + * The value of "" is actually the function's code of myFunction. + * myFunction is interpreted as a string. + * Indeed, "(" + myFunction + ")()" is a string, because function.toString() returns function's code. + */ + // const codeToExecute = "(" + myFunction + ")(" + myArgument + ");"; + const injectableScriptFunctionArgumentList = [ JSON.stringify(userSettings) ]; + + chrome.scripting.executeScript({ + "target": {"tabId": tabId, "allFrames": true}, + "func": injectableScriptFunction, + "args": injectableScriptFunctionArgumentList + }).then(results => { + if (chrome.runtime.lastError) { + console.log(chrome.runtime.lastError.message); + } + if (results.length > 0 && results[0] !== undefined) { + const data = results[0].result; + sendDataToArrowDL(data); + } + }); + }); } /* ***************************** */ -/* Collect links and media */ +/* Worker Message */ /* ***************************** */ -function collectDOMandSendData() { +chrome.runtime.onMessage.addListener((message , sender, sendResponse) => { + console.log("Message received!", message); - function myFunction(myArgument) { - const restoredSettings = myArgument; // not necessary: JSON.parse(myArgument); - let hasLinks = true; - let hasMedia = true; - let array = ""; + if (message === 'get-user-settings') { - // Options - if (restoredSettings.radioApplicationId === 1) { - array += ""; + chrome.storage.local.get((userSettings) => { + if (chrome.runtime.lastError) { + console.log(chrome.runtime.lastError.message); + console.log(`Error: ${userSettings}`); + } - } else if (restoredSettings.radioApplicationId === 2) { + if (userSettings === undefined) { + console.log(`Error: ${userSettings}`); + } else { + sendResponse(userSettings); + // console.log("Settings changed: " + JSON.stringify(userSettings)); + } + }); - if (restoredSettings.radioMediaId === 1) { - hasMedia = false; - array += "[QUICK_LINKS]"; - array += " "; + } else if (message === 'collect-dom-and-send-to-native-app') { - } else if (restoredSettings.radioMediaId === 2) { - hasLinks = false; - array += "[QUICK_MEDIA]"; - array += " "; - } + chrome.storage.local.get((userSettings) => { + collectDOMandSendData(userSettings); + }); - if (restoredSettings.startPaused === true) { - array += "[STARTED_PAUSED]"; - array += " "; - } - } + } else if (message === 'collect-dom-and-send-to-native-app-with-wizard') { - // Get the current URL - const url = document.URL; - array += "[CURRENT_URL] "; - array += url; - array += " "; - - if (hasLinks) { - // Get all elements of type - array += "[LINKS] "; - const links = document.getElementsByTagName("a"); - for (let i = 0; i < links.length; i++) { - array += links[i].href; - array += " "; - } - } + chrome.storage.local.get((userSettings) => { + userSettings.radioApplicationId = 1; // Force the Wizard to appear + collectDOMandSendData(userSettings); + }); - if (hasMedia) { - // Get all elements of type - array += "[MEDIA] "; - const pictures = document.getElementsByTagName("img"); - for (let i = 0; i < pictures.length; i++) { - array += pictures[i].src; - array += " "; - } - } - - return array; - } - - const myArgument = JSON.stringify(mySettings); + } else if ('send-to-native-app' in message) { - // We have permission to access the activeTab, so we can call chrome.tabs.executeScript. - /* Remark: - * code: "" - * The value of "" is actually the function's code of myFunction. - * myFunction is interpreted as a string. - * Indeed, "(" + myFunction + ")()" is a string, because function.toString() returns function's code. - */ - const codeToExecute = "(" + myFunction + ")(" + myArgument + ");"; + const data = message['send-to-native-app']; + console.log("Sending message to native app: " + data); + sendDataToArrowDL(data); - chrome.tabs.executeScript({ - "code": codeToExecute - }, function(results) { - if (chrome.runtime.lastError) { - console.log(chrome.runtime.lastError.message); - } - sendData(results[0]); } - ); -} - -function collectDOMandSendDataWithWizard() { - // We *hack* the settings - const previous = mySettings.radioApplicationId; - mySettings.radioApplicationId = 1; - - collectDOMandSendData(); - - mySettings.radioApplicationId = previous; -} - -/* ***************************** */ -/* Message */ -/* ***************************** */ -function handleMessage(request, sender, sendResponse) { - console.log("Message from the options.js: " + JSON.stringify(request)); - mySettings = request; - sendResponse({response: "ok"}); -} -chrome.runtime.onMessage.addListener(handleMessage); + sendResponse(true); +}); /* ***************************** */ /* Native Message */ /* ***************************** */ -function sendData(links) { - function onResponse(response) { - if (chrome.runtime.lastError) { - console.log(chrome.runtime.lastError.message); - onError(response); - } - if (response === undefined) { - onError(response); - } else { - console.log("Message from the launcher: " + response.text); - } - } - - function onError(error) { - console.log(`Error: ${error}`); - } +function sendDataToArrowDL(data) { + const message = {"text": "launch " + data}; + chrome.runtime.sendNativeMessage(application, message, (response) => { + if (chrome.runtime.lastError) { + console.log(chrome.runtime.lastError.message); + console.log(`Error: ${response}`); + } - const data = "launch " + links; - console.log("Sending message to launcher: " + data); - chrome.runtime.sendNativeMessage(application, { "text": data }, onResponse); + if (response === undefined) { + console.log(`Error: ${response}`); + } else { + console.log("Received response from native app: " + response.text); + } + }); } /* ***************************** */ diff --git a/web-extension/extension/src/chromium/manifest.json b/web-extension/extension/src/chromium/manifest.json index 1181a4e6..41217971 100644 --- a/web-extension/extension/src/chromium/manifest.json +++ b/web-extension/extension/src/chromium/manifest.json @@ -1,9 +1,9 @@ { "author": "SetVisible(0!=1)", "background": { - "scripts": ["background.js"] + "service_worker": "background.js" }, - "browser_action": { + "action": { "default_icon": { "16": "icons/icon16.png", "24": "icons/icon24.png", @@ -26,16 +26,17 @@ "64": "icons/icon64.png", "128": "icons/icon128.png" }, - "manifest_version": 2, + "manifest_version": 3, "name": "__MSG_extensionName__", "options_ui": { "page": "options.html", - "chrome_style": false + "browser_style": false }, "permissions": [ "activeTab", "contextMenus", "nativeMessaging", + "scripting", "storage", "tabs" ], diff --git a/web-extension/extension/src/chromium/options.js b/web-extension/extension/src/chromium/options.js index 715046f5..80c63bec 100644 --- a/web-extension/extension/src/chromium/options.js +++ b/web-extension/extension/src/chromium/options.js @@ -34,7 +34,7 @@ function saveOptions() { } function getOptions() { - const options = {}; + let options = {}; options["radioApplicationId"] = getApplicationRadio(); options["radioMediaId"] = getMediaRadio(); options["startPaused"] = isStartPaused(); diff --git a/web-extension/extension/src/chromium/popup.js b/web-extension/extension/src/chromium/popup.js index fbccfc4e..0f013d92 100644 --- a/web-extension/extension/src/chromium/popup.js +++ b/web-extension/extension/src/chromium/popup.js @@ -6,25 +6,22 @@ const application = "com.arrowdl.extension"; /* Native Message */ /* ***************************** */ function checkConnection() { - function onResponse(response) { + // todo chrome.runtime.sendMessage({'send-to-native-app': "areyouthere"}); + const message = {"text": "areyouthere"}; + chrome.runtime.sendNativeMessage(application, message, (response) => { if (chrome.runtime.lastError) { console.log(chrome.runtime.lastError.message); - onError(response); + console.log(`Error: ${response}`); + showWarningMessage(true); } + if (response === undefined) { - onError(response); + console.log(`Error: ${response}`); + showWarningMessage(true); } else { showWarningMessage(false); } - } - - function onError(error) { - console.log(`Error: ${error}`); - showWarningMessage(true); - } - - const data = "areyouthere"; - chrome.runtime.sendNativeMessage(application, { "text": data }, onResponse); + }); } @@ -62,9 +59,9 @@ function setVisible(name, visible) { } } -function immediateButtonLabel() { - const mediaId = getBackgroundPage().getSettingMediaId(); - const startPaused = getBackgroundPage().isSettingStartPaused(); +function immediateButtonLabel(userSettings) { + const mediaId = getSettingMediaId(userSettings); + const startPaused = isSettingStartPaused(userSettings); if (mediaId === 1) { if (startPaused) { return chrome.i18n.getMessage("popupDownloadLinksPaused") @@ -92,122 +89,41 @@ function safeInnerHtmlAssignment(elementId, label) { } /* ***************************** */ -/* FIREFOX BUG #1329304 */ +/* Events */ /* ***************************** */ -function checkIncognitoMode() { - showIncognitoWarningMessage(hasIncognitoModeBug()); -} - -function hasIncognitoModeBug() { - // Remark: - // https://developer.mozilla.org/en/docs/Mozilla/Add-ons/WebExtensions/API/runtime/getBackgroundPage - // method 'getBackgroundPage()' cannot be used in a private window in Firefox - // it always returns null. - // For more info see related bug at bugzilla. - // https://bugzilla.mozilla.org/show_bug.cgi?id=1329304 - return (chrome.extension.getBackgroundPage() === null); -} - -function showIncognitoWarningMessage(hasError) { - const x = document.getElementById("warning-area-incognito"); - if (hasError) { - x.style.display = "block"; - } else { - x.style.display = "none"; - } - if (hasError) { - setDisabled("button-start", true); - } -} - -// This function is a work-around to the Firefox Incognito Context mode Bug. -function getBackgroundPage() { - if (hasIncognitoModeBug()) { - return new DummyChromeExtensionForIncognitoMode(); - } - return chrome.extension.getBackgroundPage(); -} - -class DummyChromeExtensionForIncognitoMode { - constructor() { - } - - isSettingAskEnabled() { - return true; - } - getSettingMediaId() { - return -1; - } - isSettingStartPaused() { - return false; - } - collectDOMandSendDataWithWizard() { - // Nothing - } - collectDOMandSendData() { - // Nothing - } - - sendData(links) { - function onResponse(response) { - if (chrome.runtime.lastError) { - console.log(chrome.runtime.lastError.message); - onError(response); - } - if (response === undefined) { - onError(response); - } else { - console.log("Message from the launcher: " + response.text); - } - } +document.addEventListener('DOMContentLoaded', () => { + checkConnection(); - function onError(error) { - console.log(`Error: ${error}`); - } + // send a message to the background + chrome.runtime.sendMessage('get-user-settings', (userSettings) => { + const enabled = isSettingAskEnabled(userSettings); + setVisible("button-immediate-download", !enabled); - const data = "launch " + links; - console.log("Sending message to launcher: " + data); - chrome.runtime.sendNativeMessage(application, { "text": data }, onResponse); - } -} - -/* ***************************** */ -/* Events */ -/* ***************************** */ -function onLoaded() { - checkConnection(); - checkIncognitoMode(); - - const enabled = getBackgroundPage().isSettingAskEnabled(); - setVisible("button-immediate-download", !enabled); - - if (!enabled) { - const label = immediateButtonLabel(); - safeInnerHtmlAssignment("button-immediate-download-label", label); - } -} + if (!enabled) { + const label = immediateButtonLabel(userSettings); + safeInnerHtmlAssignment("button-immediate-download-label", label); + } + }); +}); -document.addEventListener('DOMContentLoaded', onLoaded); document.getElementById("button-start").addEventListener('click', () => { - getBackgroundPage().collectDOMandSendDataWithWizard(); + chrome.runtime.sendMessage('collect-dom-and-send-to-native-app-with-wizard'); window.close(); }); document.getElementById("button-immediate-download").addEventListener('click', () => { - getBackgroundPage().collectDOMandSendData(); + chrome.runtime.sendMessage('collect-dom-and-send-to-native-app'); window.close(); }); -document.getElementById("button-manager").addEventListener('click', () => { - const command = "[MANAGER]"; - getBackgroundPage().sendData(command); +document.getElementById("button-manager").addEventListener('click', () => { + chrome.runtime.sendMessage({'send-to-native-app': "[MANAGER]"}); window.close(); }); -document.getElementById("button-preference").addEventListener('click', () => { - const command = "[PREFS]"; - getBackgroundPage().sendData(command); +document.getElementById("button-preference").addEventListener('click', () => { + chrome.runtime.sendMessage({'send-to-native-app': "[PREFS]"}); window.close(); }); @@ -221,6 +137,27 @@ document.getElementById("button-website").addEventListener('click', () => { window.close(); }); +/* ***************************** */ +/* Options */ +/* ***************************** */ +function isSettingAskEnabled(userSettings) { + return userSettings === undefined || userSettings.radioApplicationId === undefined || userSettings.radioApplicationId === 1; +} + +function getSettingMediaId(userSettings) { + if (userSettings === undefined) { + return -1; + } + return userSettings.radioMediaId; +} + +function isSettingStartPaused(userSettings) { + if (userSettings === undefined) { + return false; + } + return userSettings.startPaused; +} + /* ***************************** */ /* Internationalization */ /* ***************************** */ diff --git a/web-extension/extension/src/firefox/background.js b/web-extension/extension/src/firefox/background.js index 08cc0f68..184a19be 100644 --- a/web-extension/extension/src/firefox/background.js +++ b/web-extension/extension/src/firefox/background.js @@ -2,21 +2,26 @@ const application = "com.arrowdl.extension"; +// let us know we're running +console.log("Background service worker has loaded via Manifest V3."); + /* ***************************** */ /* Context Menu */ /* ***************************** */ +function contextMenusCreateCallback() { + if (browser.runtime.lastError) { + console.log(browser.runtime.lastError.message); + } +}; + browser.contextMenus.removeAll( function() { function addAction(actionId, actionTitle, actionContext) { browser.contextMenus.create({ id: actionId, title: actionTitle, - icons: { - "16": "icons/icon16.png", - "32": "icons/icon32.png" - }, contexts: [actionContext] - }); + }, contextMenusCreateCallback); } addAction("save-page", browser.i18n.getMessage("contextMenuSavePage"), "page"); addAction("save-frame", browser.i18n.getMessage("contextMenuSaveFrame"), "frame"); @@ -44,175 +49,187 @@ browser.contextMenus.onClicked.addListener( ); function save_page(info, tab) { - collectDOMandSendData(); + browser.storage.local.get((userSettings) => { + collectDOMandSendData(userSettings); + }); } function save_link(info, tab) { - const safeUrl = escapeHTML(info.linkUrl); - sendData("[DOWNLOAD_LINK] " + safeUrl); + let safeUrl = escapeHTML(info.linkUrl); + sendDataToArrowDL("[DOWNLOAD_LINK] " + safeUrl); } function save_image(info, tab) { const safeUrl = escapeHTML(info.srcUrl); - sendData("[DOWNLOAD_LINK] " + safeUrl); + sendDataToArrowDL("[DOWNLOAD_LINK] " + safeUrl); } + /* ***************************** */ -/* Options */ +/* Collect links and media */ /* ***************************** */ -let mySettings = undefined; - -function getDownloadActionChoice() { - function onOptionResponse(response) { - mySettings = response; - // console.log("Settings changed: " + JSON.stringify(mySettings)); - } - function onOptionError(error) { - console.log(`Error: ${error}`); - } - const getting = browser.storage.local.get(); - getting.then(onOptionResponse, onOptionError); -} - -getDownloadActionChoice(); - -function isSettingAskEnabled() { - return mySettings === undefined || mySettings.radioApplicationId === undefined || mySettings.radioApplicationId === 1; -} - -function getSettingMediaId() { - if (mySettings === undefined) { - return -1; - } - return mySettings.radioMediaId; -} - -function isSettingStartPaused() { - if (mySettings === undefined) { - return false; - } - return mySettings.startPaused; +function collectDOMandSendData(userSettings) { + + browser.tabs.query({"active": true, "lastFocusedWindow": true}, (tabs) => { + + const tab = tabs[0]; + const tabId = tab.id; + const tabUrl = tab.url; + + if (tabUrl.startsWith("browser")) { + console.log("Nothing to download from 'browser://' or 'browser-extension://'"); + console.log("ArrowDL is disabled when the current tab is browser settings tab."); + return; + } + + function injectableScriptFunction(args) { + const restoredSettings = JSON.parse(args); + let hasLinks = true; + let hasMedia = true; + let array = ""; + + console.log(restoredSettings); + + // Options + if (restoredSettings.radioApplicationId === 1) { + array += ""; + + } else if (restoredSettings.radioApplicationId === 2) { + + if (restoredSettings.radioMediaId === 1) { + hasMedia = false; + array += "[QUICK_LINKS]"; + array += " "; + + } else if (restoredSettings.radioMediaId === 2) { + hasLinks = false; + array += "[QUICK_MEDIA]"; + array += " "; + } + + if (restoredSettings.startPaused === true) { + array += "[STARTED_PAUSED]"; + array += " "; + } + } + + // Get the current URL + const url = document.URL; + array += "[CURRENT_URL] "; + array += url; + array += " "; + + if (hasLinks) { + // Get all elements of type + array += "[LINKS] "; + const links = document.getElementsByTagName("a"); + for (let i = 0; i < links.length; i++) { + array += links[i].href; + array += " "; + } + } + + if (hasMedia) { + // Get all elements of type + array += "[MEDIA] "; + const pictures = document.getElementsByTagName("img"); + for (let i = 0; i < pictures.length; i++) { + array += pictures[i].src; + array += " "; + } + } + + return array; + } + + /* Remark: + * code: "" + * The value of "" is actually the function's code of myFunction. + * myFunction is interpreted as a string. + * Indeed, "(" + myFunction + ")()" is a string, because function.toString() returns function's code. + */ + // const codeToExecute = "(" + myFunction + ")(" + myArgument + ");"; + const injectableScriptFunctionArgumentList = [ JSON.stringify(userSettings) ]; + + browser.scripting.executeScript({ + "target": {"tabId": tabId, "allFrames": true}, + "func": injectableScriptFunction, + "args": injectableScriptFunctionArgumentList + }).then(results => { + if (browser.runtime.lastError) { + console.log(browser.runtime.lastError.message); + } + if (results.length > 0 && results[0] !== undefined) { + const data = results[0].result; + sendDataToArrowDL(data); + } + }); + }); } /* ***************************** */ -/* Collect links and media */ +/* Worker Message */ /* ***************************** */ -function collectDOMandSendData() { +browser.runtime.onMessage.addListener((message , sender, sendResponse) => { + console.log("Message received!", message); - function myFunction(myArgument) { - const restoredSettings = myArgument; // not necessary: JSON.parse(myArgument); - let hasLinks = true; - let hasMedia = true; - let array = ""; + if (message === 'get-user-settings') { - // Options - if (restoredSettings.radioApplicationId === 1) { - array += ""; + browser.storage.local.get((userSettings) => { + if (browser.runtime.lastError) { + console.log(browser.runtime.lastError.message); + console.log(`Error: ${userSettings}`); + } - } else if (restoredSettings.radioApplicationId === 2) { + if (userSettings === undefined) { + console.log(`Error: ${userSettings}`); + } else { + sendResponse(userSettings); + // console.log("Settings changed: " + JSON.stringify(userSettings)); + } + }); - if (restoredSettings.radioMediaId === 1) { - hasMedia = false; - array += "[QUICK_LINKS]"; - array += " "; + } else if (message === 'collect-dom-and-send-to-native-app') { - } else if (restoredSettings.radioMediaId === 2) { - hasLinks = false; - array += "[QUICK_MEDIA]"; - array += " "; - } + browser.storage.local.get((userSettings) => { + collectDOMandSendData(userSettings); + }); - if (restoredSettings.startPaused === true) { - array += "[STARTED_PAUSED]"; - array += " "; - } - } + } else if (message === 'collect-dom-and-send-to-native-app-with-wizard') { - // Get the current URL - const url = document.URL; - array += "[CURRENT_URL] "; - array += url; - array += " "; - - if (hasLinks) { - // Get all elements of type - array += "[LINKS] "; - const links = document.getElementsByTagName("a"); - for (let i = 0; i < links.length; i++) { - array += links[i].href; - array += " "; - } - } + browser.storage.local.get((userSettings) => { + userSettings.radioApplicationId = 1; // Force the Wizard to appear + collectDOMandSendData(userSettings); + }); - if (hasMedia) { - // Get all elements of type - array += "[MEDIA] "; - const pictures = document.getElementsByTagName("img"); - for (let i = 0; i < pictures.length; i++) { - array += pictures[i].src; - array += " "; - } - } + } else if ('send-to-native-app' in message) { - return array; - } + const data = message['send-to-native-app']; + console.log("Sending message to native app: " + data); + sendDataToArrowDL(data); - const myArgument = JSON.stringify(mySettings); - - // We have permission to access the activeTab, so we can call browser.tabs.executeScript. - /* Remark: - * code: "" - * The value of "" is actually the function's code of myFunction. - * myFunction is interpreted as a string. - * Indeed, "(" + myFunction + ")()" is a string, because function.toString() returns function's code. - */ - const codeToExecute = "(" + myFunction + ")(" + myArgument + ");"; - - browser.tabs.executeScript({ - "code": codeToExecute - }, function(results) { - sendData(results[0]); } - ); -} - -function collectDOMandSendDataWithWizard() { - // We *hack* the settings - const previous = mySettings.radioApplicationId; - mySettings.radioApplicationId = 1; - collectDOMandSendData(); - - mySettings.radioApplicationId = previous; -} - -/* ***************************** */ -/* Message */ -/* ***************************** */ -function handleMessage(request, sender, sendResponse) { - console.log("Message from the options.js: " + JSON.stringify(request)); - mySettings = request; - sendResponse({response: "ok"}); -} - -browser.runtime.onMessage.addListener(handleMessage); + sendResponse(true); +}); /* ***************************** */ /* Native Message */ /* ***************************** */ -function sendData(links) { - function onResponse(message) { - console.log(`Message from the launcher: ${message.text}`); - } - - function onError(error) { - console.log(`Error: ${error}`); - } +function sendDataToArrowDL(data) { + const message = {"text": "launch " + data}; + browser.runtime.sendNativeMessage(application, message, (response) => { + if (browser.runtime.lastError) { + console.log(browser.runtime.lastError.message); + console.log(`Error: ${response}`); + } - const data = "launch " + links; - console.log("Sending message to launcher: " + data); - const sending = browser.runtime.sendNativeMessage(application, data); - sending.then(onResponse, onError); + if (response === undefined) { + console.log(`Error: ${response}`); + } else { + console.log("Received response from native app: " + response.text); + } + }); } /* ***************************** */ diff --git a/web-extension/extension/src/firefox/manifest.json b/web-extension/extension/src/firefox/manifest.json index fbfa8662..769104cb 100644 --- a/web-extension/extension/src/firefox/manifest.json +++ b/web-extension/extension/src/firefox/manifest.json @@ -3,7 +3,7 @@ "background": { "scripts": ["background.js"] }, - "browser_action": { + "action": { "default_icon": { "16": "icons/icon16.png", "24": "icons/icon24.png", @@ -32,18 +32,18 @@ "64": "icons/icon64.png", "128": "icons/icon128.png" }, - "manifest_version": 2, + "manifest_version": 3, "name": "__MSG_extensionName__", "options_ui": { "page": "options.html", "browser_style": false }, "permissions": [ - "", "activeTab", "contextMenus", "menus", "nativeMessaging", + "scripting", "storage", "tabs" ], diff --git a/web-extension/extension/src/firefox/options.js b/web-extension/extension/src/firefox/options.js index 22795aa3..7cd7bbb6 100644 --- a/web-extension/extension/src/firefox/options.js +++ b/web-extension/extension/src/firefox/options.js @@ -8,17 +8,24 @@ const website_download_link = "https://www.arrow-dl.com/"; /* ***************************** */ function restoreOptions() { function onOptionResponse(response) { - setApplicationRadio( response.radioApplicationId ); - setMediaRadio( response.radioMediaId ); - setStartPaused( response.startPaused ); + if (browser.runtime.lastError) { + console.log(browser.runtime.lastError.message); + onOptionError(response); + } + if (response === undefined) { + onOptionError(response); + } else { + setApplicationRadio( response.radioApplicationId ); + setMediaRadio( response.radioMediaId ); + setStartPaused( response.startPaused ); + } } function onOptionError(error) { console.log(`Error: ${error}`); } - const getting = browser.storage.local.get(); - getting.then(onOptionResponse, onOptionError); + browser.storage.local.get(onOptionResponse); } function saveOptions() { @@ -27,7 +34,7 @@ function saveOptions() { } function getOptions() { - const options = {}; + let options = {}; options["radioApplicationId"] = getApplicationRadio(); options["radioMediaId"] = getMediaRadio(); options["startPaused"] = isStartPaused(); @@ -136,13 +143,21 @@ function showOptions(visible) { /* ***************************** */ function checkConnection() { function onHelloResponse(response) { - console.log(`Message from the launcher: ${response.text}`); - const messageOk = browser.i18n.getMessage("optionsOk"); - const messageDetectedPath = browser.i18n.getMessage("optionsDetectedPath"); - const connectionStatus = "✓ " + messageOk; - const details = "

" + messageDetectedPath + "
" + response.text + ""; - setConnectionStatus(connectionStatus, details, "MediumSeaGreen"); - showOptions(true); + if (browser.runtime.lastError) { + console.log(browser.runtime.lastError.message); + onHelloError(response); + } + if (response === undefined) { + onHelloError(response); + } else { + console.log(`Message from the launcher: ${response.text}`); + const messageOk = browser.i18n.getMessage("optionsOk"); + const messageDetectedPath = browser.i18n.getMessage("optionsDetectedPath"); + const connectionStatus = "✓ " + messageOk; + const details = "

" + messageDetectedPath + "
" + response.text + ""; + setConnectionStatus(connectionStatus, details, "MediumSeaGreen"); + showOptions(true); + } } function onHelloError(error) { @@ -156,8 +171,7 @@ function checkConnection() { } const data = "areyouthere"; - const sending = browser.runtime.sendNativeMessage(application, data); - sending.then(onHelloResponse, onHelloError); + browser.runtime.sendNativeMessage(application, { "text": data }, onHelloResponse); } function setConnectionStatus(connectionStatus, details, color) { @@ -196,14 +210,21 @@ function notifyBackgroundPage() { * that the options have been updated. */ function onResponse(message) { - // console.log(`Message from the background.js: ${message.response}`); + if (browser.runtime.lastError) { + console.log(browser.runtime.lastError.message); + onError(message); + } + if (message === undefined) { + onError(message); + } else { + // console.log(`Message from the background.js: ${message.response}`); + } } function onError(error) { console.log(`Error: ${error}`); } const options = getOptions(); - const sending = browser.runtime.sendMessage(options); - sending.then(onResponse, onError); + browser.runtime.sendMessage(options, onResponse); } /* ***************************** */ diff --git a/web-extension/extension/src/firefox/popup.js b/web-extension/extension/src/firefox/popup.js index 6f0f5d01..74455071 100644 --- a/web-extension/extension/src/firefox/popup.js +++ b/web-extension/extension/src/firefox/popup.js @@ -6,16 +6,22 @@ const application = "com.arrowdl.extension"; /* Native Message */ /* ***************************** */ function checkConnection() { - function onResponse(response) { - showWarningMessage(false); - } - - function onError(error) { - showWarningMessage(true); - } - const data = "areyouthere"; - const sending = browser.runtime.sendNativeMessage(application, data); - sending.then(onResponse, onError); + // todo browser.runtime.sendMessage({'send-to-native-app': "areyouthere"}); + const message = {"text": "areyouthere"}; + browser.runtime.sendNativeMessage(application, message, (response) => { + if (browser.runtime.lastError) { + console.log(browser.runtime.lastError.message); + console.log(`Error: ${response}`); + showWarningMessage(true); + } + + if (response === undefined) { + console.log(`Error: ${response}`); + showWarningMessage(true); + } else { + showWarningMessage(false); + } + }); } @@ -53,9 +59,9 @@ function setVisible(name, visible) { } } -function immediateButtonLabel() { - const mediaId = getBackgroundPage().getSettingMediaId(); - const startPaused = getBackgroundPage().isSettingStartPaused(); +function immediateButtonLabel(userSettings) { + const mediaId = getSettingMediaId(userSettings); + const startPaused = isSettingStartPaused(userSettings); if (mediaId === 1) { if (startPaused) { return browser.i18n.getMessage("popupDownloadLinksPaused") @@ -82,114 +88,42 @@ function safeInnerHtmlAssignment(elementId, label) { } } -/* ***************************** */ -/* FIREFOX BUG #1329304 */ -/* ***************************** */ -function checkIncognitoMode() { - showIncognitoWarningMessage(hasIncognitoModeBug()); -} - -function hasIncognitoModeBug() { - // Remark: - // https://developer.mozilla.org/en/docs/Mozilla/Add-ons/WebExtensions/API/runtime/getBackgroundPage - // method 'getBackgroundPage()' cannot be used in a private window in Firefox - // it always returns null. - // For more info see related bug at bugzilla. - // https://bugzilla.mozilla.org/show_bug.cgi?id=1329304 - return (chrome.extension.getBackgroundPage() === null); -} - -function showIncognitoWarningMessage(hasError) { - const x = document.getElementById("warning-area-incognito"); - if (hasError) { - x.style.display = "block"; - } else { - x.style.display = "none"; - } - if (hasError) { - setDisabled("button-start", true); - } -} - -// This function is a work-around to the Firefox Incognito Context mode Bug. -function getBackgroundPage() { - if (hasIncognitoModeBug()) { - return new DummyChromeExtensionForIncognitoMode(); - } - return chrome.extension.getBackgroundPage(); -} - -class DummyChromeExtensionForIncognitoMode { - constructor() { - } - - isSettingAskEnabled() { - return true; - } - getSettingMediaId() { - return -1; - } - isSettingStartPaused() { - return false; - } - collectDOMandSendDataWithWizard() { - // Nothing - } - collectDOMandSendData() { - // Nothing - } - - sendData(links) { - function onResponse(message) { - console.log(`Message from the launcher: ${message.text}`); - } - function onError(error) { - console.log(`Error: ${error}`); - } - const data = "launch " + links; - console.log("Sending message to launcher: " + data); - const sending = browser.runtime.sendNativeMessage(application, data); - sending.then(onResponse, onError); - } -} - /* ***************************** */ /* Events */ /* ***************************** */ -function onLoaded() { - checkConnection(); - checkIncognitoMode(); - - const enabled = getBackgroundPage().isSettingAskEnabled(); - setVisible("button-immediate-download", !enabled); - - if (!enabled) { - const label = immediateButtonLabel(); - safeInnerHtmlAssignment("button-immediate-download-label", label); - } -} +document.addEventListener('DOMContentLoaded', () => { + checkConnection(); + + // send a message to the background + browser.runtime.sendMessage('get-user-settings', (userSettings) => { + const enabled = isSettingAskEnabled(userSettings); + setVisible("button-immediate-download", !enabled); + + if (!enabled) { + const label = immediateButtonLabel(userSettings); + safeInnerHtmlAssignment("button-immediate-download-label", label); + } + }); +}); -document.addEventListener('DOMContentLoaded', onLoaded); document.getElementById("button-start").addEventListener('click', () => { - getBackgroundPage().collectDOMandSendDataWithWizard(); + browser.runtime.sendMessage('collect-dom-and-send-to-native-app-with-wizard'); window.close(); }); document.getElementById("button-immediate-download").addEventListener('click', () => { - getBackgroundPage().collectDOMandSendData(); + browser.runtime.sendMessage('collect-dom-and-send-to-native-app'); window.close(); }); -document.getElementById("button-manager").addEventListener('click', () => { - const command = "[MANAGER]"; - getBackgroundPage().sendData(command); +document.getElementById("button-manager").addEventListener('click', () => { + browser.runtime.sendMessage({'send-to-native-app': "[MANAGER]"}); window.close(); }); -document.getElementById("button-preference").addEventListener('click', () => { - const command = "[PREFS]"; - getBackgroundPage().sendData(command); +document.getElementById("button-preference").addEventListener('click', () => { + browser.runtime.sendMessage({'send-to-native-app': "[PREFS]"}); window.close(); }); @@ -203,10 +137,26 @@ document.getElementById("button-website").addEventListener('click', () => { window.close(); }); -document.getElementById("bug-link").addEventListener('click', () => { - window.open(document.getElementById("bug-link").getAttribute("href"), "_blank"); - window.close(); -}); +/* ***************************** */ +/* Options */ +/* ***************************** */ +function isSettingAskEnabled(userSettings) { + return userSettings === undefined || userSettings.radioApplicationId === undefined || userSettings.radioApplicationId === 1; +} + +function getSettingMediaId(userSettings) { + if (userSettings === undefined) { + return -1; + } + return userSettings.radioMediaId; +} + +function isSettingStartPaused(userSettings) { + if (userSettings === undefined) { + return false; + } + return userSettings.startPaused; +} /* ***************************** */ /* Internationalization */ From 8b233a78c8e4b9d5ccaa67eeb8ed154c678dcdd0 Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Sun, 7 Jan 2024 14:22:04 +0100 Subject: [PATCH 10/14] [Torrent] Add missing notifications --- src/core/torrentcontext_p.cpp | 46 +++++++++++++++++---------- src/ipc/interprocesscommunication.cpp | 4 +-- src/widgets/textedit.cpp | 4 +-- 3 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/core/torrentcontext_p.cpp b/src/core/torrentcontext_p.cpp index e94feb19..7ff9f844 100644 --- a/src/core/torrentcontext_p.cpp +++ b/src/core/torrentcontext_p.cpp @@ -1311,53 +1311,41 @@ void WorkerThread::signalizeAlert(lt::alert* a) if (auto s = lt::alert_cast(a)) { //QString hash = toString(s->info_hashes.get_best()); // emit torrentRemoved(hash); - log(s); } else if (auto s = lt::alert_cast(a)) { // lt::torrent_status::state_t oldStatus = s->prev_state; // lt::torrent_status::state_t newStatus = s->state; // emit torrentStateChanged(oldState, newState); // rem quel torrent ? - log(s); } else if (auto s = lt::alert_cast(a)) { // int piece_index = (int)s->piece_index; // emit pieceHashCheckFailed(piece_index); - log(s); } else if (auto s = lt::alert_cast(a)) { // emit torrentFinished(); - log(s); } else if (auto s = lt::alert_cast(a)) { // emit torrentPaused(); - log(s); } else if (auto s = lt::alert_cast(a)) { // emit torrentResumed(); - log(s); } else if (auto s = lt::alert_cast(a)) { // emit torrentChecked(); - log(s); } else if (auto s = lt::alert_cast(a)) { // emit torrentFastResumeFailed(); - log(s); } else if (auto s = lt::alert_cast(a)) { // emit trackeridReceived(); - log(s); } else if (auto s = lt::alert_cast(a)) { // emit torrentError(); - log(s); } else if (auto s = lt::alert_cast(a)) { // emit torrentSSLError(); - log(s); } else if (auto s = lt::alert_cast(a)) { - log(s); onTorrentAdded(s->handle, s->params, s->error); } else if (auto s = lt::alert_cast(a)) { @@ -1369,10 +1357,9 @@ void WorkerThread::signalizeAlert(lt::alert* a) // magnet extension else if (auto s = lt::alert_cast(a)) { // emit metadataFailed(); - log(s); + qWarning() << "metadata that was received was corrupt"; } else if (auto s = lt::alert_cast(a)) { - log(s); onMetadataReceived(s->handle); } @@ -1489,9 +1476,33 @@ void WorkerThread::signalizeAlert(lt::alert* a) /* storage_notification */ - // else if (auto s = lt::alert_cast(a)) { - // emit fileCompleted(index); - // } + else if (auto s = lt::alert_cast(a)) { + Q_UNUSED(s) // emit fileCompleted(index); + } + else if (auto s = lt::alert_cast(a)) { + Q_UNUSED(s) + } + else if (auto s = lt::alert_cast(a)) { + Q_UNUSED(s) + } + else if (auto s = lt::alert_cast(a)) { + Q_UNUSED(s) + } + else if (auto s = lt::alert_cast(a)) { + Q_UNUSED(s) + } + else if (auto s = lt::alert_cast(a)) { + Q_UNUSED(s) + } + else if (auto s = lt::alert_cast(a)) { + Q_UNUSED(s) + } + else if (auto s = lt::alert_cast(a)) { + Q_UNUSED(s) + } + else if (auto s = lt::alert_cast(a)) { + Q_UNUSED(s) + } else if (auto s = lt::alert_cast(a)) { // int index = (int)s->index; @@ -1653,6 +1664,7 @@ void WorkerThread::signalizeAlert(lt::alert* a) /* block_progress_notification */ else if (auto s = lt::alert_cast(a)) { Q_UNUSED(s) // emit alerts_dropped_alert(); + qWarning() << "Alert queue grew too big."; } else if (auto s = lt::alert_cast(a)) { Q_UNUSED(s) // emit socks5_alert(); diff --git a/src/ipc/interprocesscommunication.cpp b/src/ipc/interprocesscommunication.cpp index bb01999c..d7ab66f7 100644 --- a/src/ipc/interprocesscommunication.cpp +++ b/src/ipc/interprocesscommunication.cpp @@ -95,7 +95,7 @@ QString InterProcessCommunication::getCurrentUrl(const QString &message) auto resources = message.split(QChar::Space, Qt::SkipEmptyParts); for (auto i = 0; i < resources.count() - 1; ++i) { if (resources.at(i).trimmed() == C_KEYWORD_OPEN_URL) { - return resources.at(i+1).trimmed(); + return resources.at(i + 1).trimmed(); } } return {}; @@ -111,7 +111,7 @@ QString InterProcessCommunication::getDownloadLink(const QString &message) const QStringList resources = message.split(QChar::Space, Qt::SkipEmptyParts); for (int i = 0; i < resources.count() - 1; ++i) { if (resources.at(i).trimmed() == C_KEYWORD_DOWNLOAD_LINK) { - return resources.at(i+1).trimmed(); + return resources.at(i + 1).trimmed(); } } return {}; diff --git a/src/widgets/textedit.cpp b/src/widgets/textedit.cpp index dc0b25da..31d8c3ea 100644 --- a/src/widgets/textedit.cpp +++ b/src/widgets/textedit.cpp @@ -633,9 +633,9 @@ void TextEdit::removeBlockSelection(const QString &text) cursor.setPosition( block.position() + endPos, QTextCursor::KeepAnchor); cursor.removeSelectedText(); } else { - cursor.setPosition( block.position()+block.length()-1, QTextCursor::MoveAnchor); + cursor.setPosition( block.position()+block.length() - 1, QTextCursor::MoveAnchor); QString str = ""; - str.fill(' ', leftColumn-block.length()+1 ); // str == " " + str.fill(' ', leftColumn-block.length() + 1 ); // str == " " cursor.insertText( str ); } if (!text.isEmpty()) { From 7282b4a338cab5c22bc3460e40dffb860af7d8f1 Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Sun, 7 Jan 2024 15:42:40 +0100 Subject: [PATCH 11/14] [UI] Fix icons --- src/resources.qrc | 20 ++++++++++++++ .../scalable/actions/queue-completed.svg | 1 + .../scalable/actions/queue-idle.svg | 1 + .../scalable/actions/queue-paused.svg | 1 + .../scalable/actions/queue-play.svg | 1 + .../scalable/actions/queue-stop.svg | 1 + .../scalable/actions/queue-completed.svg | 1 + .../default/scalable/actions/queue-idle.svg | 1 + .../default/scalable/actions/queue-paused.svg | 1 + .../default/scalable/actions/queue-play.svg | 1 + .../default/scalable/actions/queue-stop.svg | 1 + .../scalable/actions/queue-completed.svg | 1 + .../flat-dark/scalable/actions/queue-idle.svg | 1 + .../scalable/actions/queue-paused.svg | 1 + .../flat-dark/scalable/actions/queue-play.svg | 1 + .../flat-dark/scalable/actions/queue-stop.svg | 1 + .../flat/scalable/actions/queue-completed.svg | 1 + .../flat/scalable/actions/queue-idle.svg | 1 + .../flat/scalable/actions/queue-paused.svg | 1 + .../flat/scalable/actions/queue-play.svg | 1 + .../flat/scalable/actions/queue-stop.svg | 1 + src/widgets/checkableitemdelegate.h | 2 +- src/widgets/customstyleoptionprogressbar.h | 6 ++--- src/widgets/downloadqueueview.cpp | 26 ++++++++----------- 24 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 src/resources/icons/default-dark/scalable/actions/queue-completed.svg create mode 100644 src/resources/icons/default-dark/scalable/actions/queue-idle.svg create mode 100644 src/resources/icons/default-dark/scalable/actions/queue-paused.svg create mode 100644 src/resources/icons/default-dark/scalable/actions/queue-play.svg create mode 100644 src/resources/icons/default-dark/scalable/actions/queue-stop.svg create mode 100644 src/resources/icons/default/scalable/actions/queue-completed.svg create mode 100644 src/resources/icons/default/scalable/actions/queue-idle.svg create mode 100644 src/resources/icons/default/scalable/actions/queue-paused.svg create mode 100644 src/resources/icons/default/scalable/actions/queue-play.svg create mode 100644 src/resources/icons/default/scalable/actions/queue-stop.svg create mode 100644 src/resources/icons/flat-dark/scalable/actions/queue-completed.svg create mode 100644 src/resources/icons/flat-dark/scalable/actions/queue-idle.svg create mode 100644 src/resources/icons/flat-dark/scalable/actions/queue-paused.svg create mode 100644 src/resources/icons/flat-dark/scalable/actions/queue-play.svg create mode 100644 src/resources/icons/flat-dark/scalable/actions/queue-stop.svg create mode 100644 src/resources/icons/flat/scalable/actions/queue-completed.svg create mode 100644 src/resources/icons/flat/scalable/actions/queue-idle.svg create mode 100644 src/resources/icons/flat/scalable/actions/queue-paused.svg create mode 100644 src/resources/icons/flat/scalable/actions/queue-play.svg create mode 100644 src/resources/icons/flat/scalable/actions/queue-stop.svg diff --git a/src/resources.qrc b/src/resources.qrc index bac3e2bb..c2770f58 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -55,6 +55,11 @@ resources/icons/default/scalable/actions/preference-schedule.svg resources/icons/default/scalable/actions/preference-security.svg resources/icons/default/scalable/actions/preference-torrent.svg + resources/icons/default/scalable/actions/queue-completed.svg + resources/icons/default/scalable/actions/queue-idle.svg + resources/icons/default/scalable/actions/queue-paused.svg + resources/icons/default/scalable/actions/queue-play.svg + resources/icons/default/scalable/actions/queue-stop.svg resources/icons/default/scalable/actions/remove-all.svg resources/icons/default/scalable/actions/remove-completed.svg resources/icons/default/scalable/actions/remove-downloaded.svg @@ -119,6 +124,11 @@ resources/icons/default-dark/scalable/actions/preference-schedule.svg resources/icons/default-dark/scalable/actions/preference-security.svg resources/icons/default-dark/scalable/actions/preference-torrent.svg + resources/icons/default-dark/scalable/actions/queue-completed.svg + resources/icons/default-dark/scalable/actions/queue-idle.svg + resources/icons/default-dark/scalable/actions/queue-paused.svg + resources/icons/default-dark/scalable/actions/queue-play.svg + resources/icons/default-dark/scalable/actions/queue-stop.svg resources/icons/default-dark/scalable/actions/remove-all.svg resources/icons/default-dark/scalable/actions/remove-completed.svg resources/icons/default-dark/scalable/actions/remove-downloaded.svg @@ -183,6 +193,11 @@ resources/icons/flat/scalable/actions/preference-schedule.svg resources/icons/flat/scalable/actions/preference-security.svg resources/icons/flat/scalable/actions/preference-torrent.svg + resources/icons/flat/scalable/actions/queue-completed.svg + resources/icons/flat/scalable/actions/queue-idle.svg + resources/icons/flat/scalable/actions/queue-paused.svg + resources/icons/flat/scalable/actions/queue-play.svg + resources/icons/flat/scalable/actions/queue-stop.svg resources/icons/flat/scalable/actions/remove-all.svg resources/icons/flat/scalable/actions/remove-completed.svg resources/icons/flat/scalable/actions/remove-downloaded.svg @@ -247,6 +262,11 @@ resources/icons/flat-dark/scalable/actions/preference-schedule.svg resources/icons/flat-dark/scalable/actions/preference-security.svg resources/icons/flat-dark/scalable/actions/preference-torrent.svg + resources/icons/flat-dark/scalable/actions/queue-completed.svg + resources/icons/flat-dark/scalable/actions/queue-idle.svg + resources/icons/flat-dark/scalable/actions/queue-paused.svg + resources/icons/flat-dark/scalable/actions/queue-play.svg + resources/icons/flat-dark/scalable/actions/queue-stop.svg resources/icons/flat-dark/scalable/actions/remove-all.svg resources/icons/flat-dark/scalable/actions/remove-completed.svg resources/icons/flat-dark/scalable/actions/remove-downloaded.svg diff --git a/src/resources/icons/default-dark/scalable/actions/queue-completed.svg b/src/resources/icons/default-dark/scalable/actions/queue-completed.svg new file mode 100644 index 00000000..b7fb2408 --- /dev/null +++ b/src/resources/icons/default-dark/scalable/actions/queue-completed.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/default-dark/scalable/actions/queue-idle.svg b/src/resources/icons/default-dark/scalable/actions/queue-idle.svg new file mode 100644 index 00000000..f5978560 --- /dev/null +++ b/src/resources/icons/default-dark/scalable/actions/queue-idle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/default-dark/scalable/actions/queue-paused.svg b/src/resources/icons/default-dark/scalable/actions/queue-paused.svg new file mode 100644 index 00000000..85a3b3f5 --- /dev/null +++ b/src/resources/icons/default-dark/scalable/actions/queue-paused.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/default-dark/scalable/actions/queue-play.svg b/src/resources/icons/default-dark/scalable/actions/queue-play.svg new file mode 100644 index 00000000..929140df --- /dev/null +++ b/src/resources/icons/default-dark/scalable/actions/queue-play.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/default-dark/scalable/actions/queue-stop.svg b/src/resources/icons/default-dark/scalable/actions/queue-stop.svg new file mode 100644 index 00000000..0f0a9730 --- /dev/null +++ b/src/resources/icons/default-dark/scalable/actions/queue-stop.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/default/scalable/actions/queue-completed.svg b/src/resources/icons/default/scalable/actions/queue-completed.svg new file mode 100644 index 00000000..5391e529 --- /dev/null +++ b/src/resources/icons/default/scalable/actions/queue-completed.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/default/scalable/actions/queue-idle.svg b/src/resources/icons/default/scalable/actions/queue-idle.svg new file mode 100644 index 00000000..9decb114 --- /dev/null +++ b/src/resources/icons/default/scalable/actions/queue-idle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/default/scalable/actions/queue-paused.svg b/src/resources/icons/default/scalable/actions/queue-paused.svg new file mode 100644 index 00000000..0f93a033 --- /dev/null +++ b/src/resources/icons/default/scalable/actions/queue-paused.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/default/scalable/actions/queue-play.svg b/src/resources/icons/default/scalable/actions/queue-play.svg new file mode 100644 index 00000000..3ba89d16 --- /dev/null +++ b/src/resources/icons/default/scalable/actions/queue-play.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/default/scalable/actions/queue-stop.svg b/src/resources/icons/default/scalable/actions/queue-stop.svg new file mode 100644 index 00000000..25b42d56 --- /dev/null +++ b/src/resources/icons/default/scalable/actions/queue-stop.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/flat-dark/scalable/actions/queue-completed.svg b/src/resources/icons/flat-dark/scalable/actions/queue-completed.svg new file mode 100644 index 00000000..b7fb2408 --- /dev/null +++ b/src/resources/icons/flat-dark/scalable/actions/queue-completed.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/flat-dark/scalable/actions/queue-idle.svg b/src/resources/icons/flat-dark/scalable/actions/queue-idle.svg new file mode 100644 index 00000000..f5978560 --- /dev/null +++ b/src/resources/icons/flat-dark/scalable/actions/queue-idle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/flat-dark/scalable/actions/queue-paused.svg b/src/resources/icons/flat-dark/scalable/actions/queue-paused.svg new file mode 100644 index 00000000..85a3b3f5 --- /dev/null +++ b/src/resources/icons/flat-dark/scalable/actions/queue-paused.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/flat-dark/scalable/actions/queue-play.svg b/src/resources/icons/flat-dark/scalable/actions/queue-play.svg new file mode 100644 index 00000000..929140df --- /dev/null +++ b/src/resources/icons/flat-dark/scalable/actions/queue-play.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/flat-dark/scalable/actions/queue-stop.svg b/src/resources/icons/flat-dark/scalable/actions/queue-stop.svg new file mode 100644 index 00000000..0f0a9730 --- /dev/null +++ b/src/resources/icons/flat-dark/scalable/actions/queue-stop.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/flat/scalable/actions/queue-completed.svg b/src/resources/icons/flat/scalable/actions/queue-completed.svg new file mode 100644 index 00000000..5391e529 --- /dev/null +++ b/src/resources/icons/flat/scalable/actions/queue-completed.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/flat/scalable/actions/queue-idle.svg b/src/resources/icons/flat/scalable/actions/queue-idle.svg new file mode 100644 index 00000000..9decb114 --- /dev/null +++ b/src/resources/icons/flat/scalable/actions/queue-idle.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/flat/scalable/actions/queue-paused.svg b/src/resources/icons/flat/scalable/actions/queue-paused.svg new file mode 100644 index 00000000..0f93a033 --- /dev/null +++ b/src/resources/icons/flat/scalable/actions/queue-paused.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/flat/scalable/actions/queue-play.svg b/src/resources/icons/flat/scalable/actions/queue-play.svg new file mode 100644 index 00000000..3ba89d16 --- /dev/null +++ b/src/resources/icons/flat/scalable/actions/queue-play.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/resources/icons/flat/scalable/actions/queue-stop.svg b/src/resources/icons/flat/scalable/actions/queue-stop.svg new file mode 100644 index 00000000..25b42d56 --- /dev/null +++ b/src/resources/icons/flat/scalable/actions/queue-stop.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/widgets/checkableitemdelegate.h b/src/widgets/checkableitemdelegate.h index 1645b061..4ecc5b84 100644 --- a/src/widgets/checkableitemdelegate.h +++ b/src/widgets/checkableitemdelegate.h @@ -38,7 +38,7 @@ class CheckableItemDelegate : public QStyledItemDelegate bool editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index) override; private: - QIcon m_checkIcon; + QIcon m_checkIcon = {}; }; diff --git a/src/widgets/customstyleoptionprogressbar.h b/src/widgets/customstyleoptionprogressbar.h index f0e3cd92..04f4242a 100644 --- a/src/widgets/customstyleoptionprogressbar.h +++ b/src/widgets/customstyleoptionprogressbar.h @@ -28,9 +28,9 @@ class CustomStyleOptionProgressBar : public QStyleOptionProgressBar CustomStyleOptionProgressBar() = default; QColor color{Qt::blue}; - QIcon icon{QIcon()}; - bool hasSegments{false}; - QBitArray segments; + QIcon icon = {}; + bool hasSegments = false; + QBitArray segments = {}; }; #endif // WIDGETS_CUSTOM_STYLE_OPTION_PROGRESS_BAR_H diff --git a/src/widgets/downloadqueueview.cpp b/src/widgets/downloadqueueview.cpp index ffb6775d..ed04df2a 100644 --- a/src/widgets/downloadqueueview.cpp +++ b/src/widgets/downloadqueueview.cpp @@ -150,11 +150,11 @@ class QueueViewItemDelegate : public QStyledItemDelegate void restylizeUi(); private: - QIcon m_idleIcon; - QIcon m_resumeIcon; - QIcon m_pauseIcon; - QIcon m_stopIcon; - QIcon m_completedIcon; + QIcon m_idleIcon = {}; + QIcon m_resumeIcon = {}; + QIcon m_pauseIcon = {}; + QIcon m_stopIcon = {}; + QIcon m_completedIcon = {}; QColor stateColor(IDownloadItem::State state) const; QIcon stateIcon(IDownloadItem::State state) const; @@ -163,11 +163,7 @@ class QueueViewItemDelegate : public QStyledItemDelegate QueueViewItemDelegate::QueueViewItemDelegate(QObject *parent) : QStyledItemDelegate(parent) { - m_idleIcon.addPixmap(QPixmap(":/resources/icons/default/16x16/actions/play-idle.png"), QIcon::Normal, QIcon::On); - m_resumeIcon.addPixmap(QPixmap(":/resources/icons/default/16x16/actions/play-resume.png"), QIcon::Normal, QIcon::On); - m_pauseIcon.addPixmap(QPixmap(":/resources/icons/default/16x16/actions/play-pause.png"), QIcon::Normal, QIcon::On); - m_stopIcon.addPixmap(QPixmap(":/resources/icons/default/16x16/actions/play-stop.png"), QIcon::Normal, QIcon::On); - m_completedIcon.addPixmap(QPixmap(":/resources/icons/default/16x16/actions/remove-completed.png"), QIcon::Normal, QIcon::On); + restylizeUi(); } void QueueViewItemDelegate::restylizeUi() @@ -178,11 +174,11 @@ void QueueViewItemDelegate::restylizeUi() m_stopIcon = {}; m_completedIcon = {}; - m_idleIcon.addPixmap(QIcon::fromTheme("play-idle").pixmap(16), QIcon::Normal, QIcon::On); - m_resumeIcon.addPixmap(QIcon::fromTheme("play-resume").pixmap(16), QIcon::Normal, QIcon::On); - m_pauseIcon.addPixmap(QIcon::fromTheme("play-pause").pixmap(16), QIcon::Normal, QIcon::On); - m_stopIcon.addPixmap(QIcon::fromTheme("play-stop").pixmap(16), QIcon::Normal, QIcon::On); - m_completedIcon.addPixmap(QIcon::fromTheme("remove-completed").pixmap(16), QIcon::Normal, QIcon::On); + m_idleIcon.addPixmap(QIcon::fromTheme("queue-idle").pixmap(16), QIcon::Normal, QIcon::On); + m_resumeIcon.addPixmap(QIcon::fromTheme("queue-play").pixmap(16), QIcon::Normal, QIcon::On); + m_pauseIcon.addPixmap(QIcon::fromTheme("queue-paused").pixmap(16), QIcon::Normal, QIcon::On); + m_stopIcon.addPixmap(QIcon::fromTheme("queue-stop").pixmap(16), QIcon::Normal, QIcon::On); + m_completedIcon.addPixmap(QIcon::fromTheme("queue-completed").pixmap(16), QIcon::Normal, QIcon::On); } void QueueViewItemDelegate::paint( From 2c49cdd525c7debfc781d4cfc96bc0ad7e2d13e5 Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Sun, 7 Jan 2024 16:05:55 +0100 Subject: [PATCH 12/14] [UI] Fix glitches with dark palette --- src/core/theme.cpp | 12 ++++++---- src/widgets/checkableitemdelegate.cpp | 24 +++++++++++-------- src/widgets/customstyle.cpp | 17 ++++++++------ src/widgets/customstyleoptionprogressbar.h | 2 +- src/widgets/downloadqueueview.cpp | 18 +++++++-------- src/widgets/globals.h | 14 +++++------ src/widgets/torrentpiecemap.cpp | 19 +++++++++++---- src/widgets/torrentprogressbar.cpp | 9 ++++---- src/widgets/torrentwidget.cpp | 27 ++++++++++++---------- 9 files changed, 82 insertions(+), 60 deletions(-) diff --git a/src/core/theme.cpp b/src/core/theme.cpp index 4b1908d3..c42df974 100644 --- a/src/core/theme.cpp +++ b/src/core/theme.cpp @@ -168,6 +168,10 @@ int Theme::fromColorScheme(const QString &colorScheme) /*! * Modify palette to dark. * + * Recommandation: + * Google Material Design Guidelines. + * https://design.google/library/material-design-dark-theme + * * Inspiration: * https://github.com/Jorgen-VikingGod/Qt-Frameless-Window-DarkStyle/blob/master/DarkStyle.cpp */ @@ -191,7 +195,7 @@ static void polishDark(QPalette &palette) palette.setColor(QPalette::Window, QColor(53, 53, 53)); palette.setColor(QPalette::Shadow, QColor(20, 20, 20)); // -- - palette.setColor(QPalette::Highlight, QColor(42, 130, 218)); + palette.setColor(QPalette::Highlight, QColor(26, 85, 145)); // custom palette.setColor(QPalette::Disabled, QPalette::Highlight, QColor(80, 80, 80)); palette.setColor(QPalette::HighlightedText, Qt::white); palette.setColor(QPalette::Disabled, QPalette::HighlightedText, QColor(127, 127, 127)); @@ -239,11 +243,11 @@ void Theme::applyTheme(const QMap &map) : QLatin1String("default") ); } - auto dark_palette = qApp->style()->standardPalette(); + auto palette = qApp->style()->standardPalette(); if (isDarkMode) { - polishDark(dark_palette); + polishDark(palette); } - qApp->setPalette(dark_palette); // emits QEvent::PaletteChange + qApp->setPalette(palette); // emits QEvent::PaletteChange qApp->setStyle(new CustomStyle(platformStyle)); // emits QEvent::StyleChange } diff --git a/src/widgets/checkableitemdelegate.cpp b/src/widgets/checkableitemdelegate.cpp index cafcf4b7..6176fe88 100644 --- a/src/widgets/checkableitemdelegate.cpp +++ b/src/widgets/checkableitemdelegate.cpp @@ -50,26 +50,30 @@ void CheckableItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem QStyleOptionViewItem myOption = option; initStyleOption(&myOption, index); - myOption.palette.setColor(QPalette::All, QPalette::Window, s_white); - myOption.palette.setColor(QPalette::All, QPalette::WindowText, s_black); - myOption.palette.setColor(QPalette::All, QPalette::Highlight, s_lightBlue); - myOption.palette.setColor(QPalette::All, QPalette::HighlightedText, s_black); + auto palette = qApp->palette(); + myOption.palette.setColor(QPalette::All, QPalette::Window, palette.color(QPalette::Base)); + myOption.palette.setColor(QPalette::All, QPalette::WindowText, palette.color(QPalette::WindowText)); + myOption.palette.setColor(QPalette::All, QPalette::Highlight, palette.color(QPalette::Highlight)); + myOption.palette.setColor(QPalette::All, QPalette::HighlightedText, palette.color(QPalette::HighlightedText)); auto sibling = getSiblingAtColumn(index, 0); auto checked = index.model()->data(sibling, CheckableTableModel::CheckStateRole).toBool(); if (checked) { - myOption.palette.setColor(QPalette::All, QPalette::Window, s_lightYellow); - myOption.palette.setColor(QPalette::All, QPalette::Highlight, s_darkYellow); - painter->fillRect(myOption.rect, s_lightYellow); // hack + auto bgColor = myOption.palette.color(QPalette::Active, QPalette::Window); + auto isDarkMode = bgColor.lightness() < 128; + + auto lightYellow = isDarkMode ? s_dark_lightYellow : s_lightYellow; + auto darkYellow = isDarkMode ? s_dark_darkYellow : s_darkYellow; + + myOption.palette.setColor(QPalette::All, QPalette::Window, lightYellow); + myOption.palette.setColor(QPalette::All, QPalette::Highlight, darkYellow); + painter->fillRect(myOption.rect, lightYellow); // hack } if (myOption.state & QStyle::State_Selected) { myOption.font.setBold(true); } - // Otherwise it's another color - myOption.palette.setColor(QPalette::Active, QPalette::HighlightedText, myOption.palette.color(QPalette::Active, QPalette::Text)); - /* Inactive palette keep same colors as Active */ myOption.palette.setColor(QPalette::Inactive, QPalette::Base, myOption.palette.color(QPalette::Active, QPalette::Base)); myOption.palette.setColor(QPalette::Inactive, QPalette::Highlight, myOption.palette.color(QPalette::Active, QPalette::Highlight)); diff --git a/src/widgets/customstyle.cpp b/src/widgets/customstyle.cpp index 001bc9a2..67cc465d 100644 --- a/src/widgets/customstyle.cpp +++ b/src/widgets/customstyle.cpp @@ -78,6 +78,10 @@ void CustomStyle::drawControl(ControlElement element, const QStyleOption *opt, p->setBrush(bgColor); p->drawRect(pb->rect); + // 0 (dark) < lightness < 255 (light) + auto isDarkMode = bgColor.lightness() < 128; + auto barBgColor = isDarkMode ? bgColor.lighter(300) : bgColor.darker(105); + /* Draw the icon */ if (hasIcon) { auto size = ICON_SIZE; @@ -102,7 +106,7 @@ void CustomStyle::drawControl(ControlElement element, const QStyleOption *opt, frameRect.setRight(frameRect.right() - marginH); p->setPen(QPen(s_darkGrey, 1)); - p->setBrush(s_lightGrey); + p->setBrush(barBgColor); p->drawRect(frameRect); /* Draw the progress bar indicator */ @@ -131,11 +135,10 @@ void CustomStyle::drawControl(ControlElement element, const QStyleOption *opt, auto size = segments.size(); QImage segmentImage(qMax(1, size), 1, QImage::Format_RGB32); - segmentImage.fill(s_lightGrey); - auto rgb = color.rgb(); + segmentImage.fill(barBgColor.rgb()); for (auto i = 0; i < size; ++i) { if (segments.testBit(i)) { - segmentImage.setPixel(i, 0, rgb); + segmentImage.setPixel(i, 0, color.rgb()); } } auto segmentPixmap = QPixmap::fromImage(segmentImage); @@ -157,10 +160,10 @@ void CustomStyle::drawControl(ControlElement element, const QStyleOption *opt, indicatorRect.setBottom(indicatorRect.bottom() + 1 - margin); } - if (progress < 0 || (minimum == 0 && maximum == 0)) { - auto rgb = color.rgb(); + if (progress < 0 || (minimum == 0 && maximum == 0)) { auto textureImage = m_textureImage; - textureImage.setColor(1, rgb); + textureImage.setColor(0, barBgColor.rgb()); + textureImage.setColor(1, color.rgb()); auto pixmap = QPixmap::fromImage(textureImage); brush.setTexture(pixmap); diff --git a/src/widgets/customstyleoptionprogressbar.h b/src/widgets/customstyleoptionprogressbar.h index 04f4242a..26d197ac 100644 --- a/src/widgets/customstyleoptionprogressbar.h +++ b/src/widgets/customstyleoptionprogressbar.h @@ -27,7 +27,7 @@ class CustomStyleOptionProgressBar : public QStyleOptionProgressBar public: CustomStyleOptionProgressBar() = default; - QColor color{Qt::blue}; + QColor color = {Qt::blue}; QIcon icon = {}; bool hasSegments = false; QBitArray segments = {}; diff --git a/src/widgets/downloadqueueview.cpp b/src/widgets/downloadqueueview.cpp index ed04df2a..19de02d1 100644 --- a/src/widgets/downloadqueueview.cpp +++ b/src/widgets/downloadqueueview.cpp @@ -138,7 +138,7 @@ class QueueViewItemDelegate : public QStyledItemDelegate explicit QueueViewItemDelegate(QObject *parent = nullptr); // painting - void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const override; + void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override; // editing QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const override; @@ -181,10 +181,7 @@ void QueueViewItemDelegate::restylizeUi() m_completedIcon.addPixmap(QIcon::fromTheme("queue-completed").pixmap(16), QIcon::Normal, QIcon::On); } -void QueueViewItemDelegate::paint( - QPainter *painter, - const QStyleOptionViewItem &option, - const QModelIndex &index ) const +void QueueViewItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const { QStyleOptionViewItem myOption = option; initStyleOption(&myOption, index); @@ -193,15 +190,16 @@ void QueueViewItemDelegate::paint( myOption.font.setBold(true); } - myOption.palette.setColor(QPalette::All, QPalette::Window, s_white); - myOption.palette.setColor(QPalette::All, QPalette::WindowText, s_black); - myOption.palette.setColor(QPalette::All, QPalette::Highlight, s_lightBlue); - myOption.palette.setColor(QPalette::All, QPalette::HighlightedText, s_black); + auto palette = qApp->palette(); + myOption.palette.setColor(QPalette::All, QPalette::Window, palette.color(QPalette::Base)); + myOption.palette.setColor(QPalette::All, QPalette::WindowText, palette.color(QPalette::WindowText)); + myOption.palette.setColor(QPalette::All, QPalette::Highlight, palette.color(QPalette::Highlight)); + myOption.palette.setColor(QPalette::All, QPalette::HighlightedText, palette.color(QPalette::HighlightedText)); if (index.column() == COL_0_FILE_NAME) { const QUrl url(myOption.text); - const QPixmap pixmap = MimeDatabase::fileIcon(url, 16); + auto pixmap = MimeDatabase::fileIcon(url, 16); myOption.icon.addPixmap(pixmap); myOption.decorationAlignment = Qt::AlignHCenter | Qt::AlignVCenter; diff --git a/src/widgets/globals.h b/src/widgets/globals.h index 052fb5cb..5c6b7108 100644 --- a/src/widgets/globals.h +++ b/src/widgets/globals.h @@ -21,26 +21,26 @@ /* Constant */ -static const QColor s_black = QColor(0, 0, 0); -static const QColor s_blue = QColor(143, 224, 252); +// Light Mode static const QColor s_darkGreen = QColor(0, 143, 0); static const QColor s_darkGrey = QColor(160, 160, 160); static const QColor s_darkRed = QColor(177, 40, 1); static const QColor s_darkPurple = QColor(64, 32, 64); -static const QColor s_darkYellow = QColor(210, 210, 100); +static const QColor s_darkYellow = QColor(191, 191, 55); static const QColor s_green = QColor(170, 224, 97); static const QColor s_grey = QColor(200, 200, 200); -static const QColor s_lightBlue = QColor(205, 232, 255); -static const QColor s_lightGreen = QColor(236, 255, 179); static const QColor s_lightGrey = QColor(240, 240, 240); -static const QColor s_lightRed = QColor(224, 97, 170); static const QColor s_lightYellow = QColor(255, 255, 179); static const QColor s_orange = QColor(255, 204, 0); static const QColor s_red = QColor(205, 0, 0); static const QColor s_purple = QColor(200, 191, 231); -static const QColor s_white = QColor(255, 255, 255); +// Dark Mode +static const QColor s_dark_lightYellow = QColor(85, 85, 60); +static const QColor s_dark_darkYellow = QColor(113, 113, 37); +static const QColor s_darkOrange = QColor(128, 102, 0); + static const char* const s_xpm[] = { "16 16 2 1", " c #F0F0F0", // light grey diff --git a/src/widgets/torrentpiecemap.cpp b/src/widgets/torrentpiecemap.cpp index ab151ad2..33925d9b 100644 --- a/src/widgets/torrentpiecemap.cpp +++ b/src/widgets/torrentpiecemap.cpp @@ -36,11 +36,20 @@ static QColor color(TorrentPieceItem::Status status) { + auto palette = qApp->palette(); + auto bgColor = palette.color(QPalette::Active, QPalette::Window); + auto isDarkMode = bgColor.lightness() < 128; + + auto color1 = isDarkMode ? s_darkGrey : s_lightGrey; + auto color2 = isDarkMode ? s_darkOrange : s_orange; + auto color3 = isDarkMode ? s_darkGreen : s_green; + auto color4 = isDarkMode ? s_darkPurple : s_purple; + switch (status) { - case TorrentPieceItem::Status::NotAvailable: return s_lightGrey; - case TorrentPieceItem::Status::Available: return s_orange; - case TorrentPieceItem::Status::Downloaded: return s_green; - case TorrentPieceItem::Status::Verified: return s_purple; + case TorrentPieceItem::Status::NotAvailable: return color1; + case TorrentPieceItem::Status::Available: return color2; + case TorrentPieceItem::Status::Downloaded: return color3; + case TorrentPieceItem::Status::Verified: return color4; } Q_UNREACHABLE(); } @@ -52,7 +61,7 @@ static void colorize(QWidget *widget, TorrentPieceItem::Status status) pal.setColor(QPalette::Window, _color); widget->setAutoFillBackground(true); widget->setPalette(pal); - widget->setStyleSheet(QString()); + widget->setStyleSheet({}); } static QString decorate(int count, TorrentFileInfo::Priority priority) diff --git a/src/widgets/torrentprogressbar.cpp b/src/widgets/torrentprogressbar.cpp index a71eb7f3..816360c1 100644 --- a/src/widgets/torrentprogressbar.cpp +++ b/src/widgets/torrentprogressbar.cpp @@ -62,10 +62,11 @@ void TorrentProgressBar::paintEvent(QPaintEvent *) CustomStyleOptionProgressBar myOption; initStyleOption(&myOption); - myOption.palette.setColor(QPalette::All, QPalette::Window, s_white); - myOption.palette.setColor(QPalette::All, QPalette::WindowText, s_black); - myOption.palette.setColor(QPalette::All, QPalette::Highlight, s_lightBlue); - myOption.palette.setColor(QPalette::All, QPalette::HighlightedText, s_black); + auto palette = qApp->palette(); + myOption.palette.setColor(QPalette::All, QPalette::Window, palette.color(QPalette::Base)); + myOption.palette.setColor(QPalette::All, QPalette::WindowText, palette.color(QPalette::WindowText)); + myOption.palette.setColor(QPalette::All, QPalette::Highlight, palette.color(QPalette::Highlight)); + myOption.palette.setColor(QPalette::All, QPalette::HighlightedText, palette.color(QPalette::HighlightedText)); auto progress = value(); diff --git a/src/widgets/torrentwidget.cpp b/src/widgets/torrentwidget.cpp index f4376dd9..f87848b0 100644 --- a/src/widgets/torrentwidget.cpp +++ b/src/widgets/torrentwidget.cpp @@ -137,10 +137,11 @@ void FileTableViewItemDelegate::paint(QPainter *painter, const QStyleOptionViewI QStyleOptionViewItem myOption = option; initStyleOption(&myOption, index); - myOption.palette.setColor(QPalette::All, QPalette::Window, s_white); - myOption.palette.setColor(QPalette::All, QPalette::WindowText, s_black); - myOption.palette.setColor(QPalette::All, QPalette::Highlight, s_lightBlue); - myOption.palette.setColor(QPalette::All, QPalette::HighlightedText, s_black); + auto palette = qApp->palette(); + myOption.palette.setColor(QPalette::All, QPalette::Window, palette.color(QPalette::Base)); + myOption.palette.setColor(QPalette::All, QPalette::WindowText, palette.color(QPalette::WindowText)); + myOption.palette.setColor(QPalette::All, QPalette::Highlight, palette.color(QPalette::Highlight)); + myOption.palette.setColor(QPalette::All, QPalette::HighlightedText, palette.color(QPalette::HighlightedText)); if (myOption.state & QStyle::State_Selected) { myOption.font.setBold(true); @@ -186,10 +187,11 @@ void PeerTableViewItemDelegate::paint(QPainter *painter, const QStyleOptionViewI QStyleOptionViewItem myOption = option; initStyleOption(&myOption, index); - myOption.palette.setColor(QPalette::All, QPalette::Window, s_white); - myOption.palette.setColor(QPalette::All, QPalette::WindowText, s_black); - myOption.palette.setColor(QPalette::All, QPalette::Highlight, s_lightBlue); - myOption.palette.setColor(QPalette::All, QPalette::HighlightedText, s_black); + auto palette = qApp->palette(); + myOption.palette.setColor(QPalette::All, QPalette::Window, palette.color(QPalette::Base)); + myOption.palette.setColor(QPalette::All, QPalette::WindowText, palette.color(QPalette::WindowText)); + myOption.palette.setColor(QPalette::All, QPalette::Highlight, palette.color(QPalette::Highlight)); + myOption.palette.setColor(QPalette::All, QPalette::HighlightedText, palette.color(QPalette::HighlightedText)); if (myOption.state & QStyle::State_Selected) { myOption.font.setBold(true); @@ -246,10 +248,11 @@ void TrackerTableViewItemDelegate::paint(QPainter *painter, const QStyleOptionVi QStyleOptionViewItem myOption = option; initStyleOption(&myOption, index); - myOption.palette.setColor(QPalette::All, QPalette::Window, s_white); - myOption.palette.setColor(QPalette::All, QPalette::WindowText, s_black); - myOption.palette.setColor(QPalette::All, QPalette::Highlight, s_lightBlue); - myOption.palette.setColor(QPalette::All, QPalette::HighlightedText, s_black); + auto palette = qApp->palette(); + myOption.palette.setColor(QPalette::All, QPalette::Window, palette.color(QPalette::Base)); + myOption.palette.setColor(QPalette::All, QPalette::WindowText, palette.color(QPalette::WindowText)); + myOption.palette.setColor(QPalette::All, QPalette::Highlight, palette.color(QPalette::Highlight)); + myOption.palette.setColor(QPalette::All, QPalette::HighlightedText, palette.color(QPalette::HighlightedText)); if (myOption.state & QStyle::State_Selected) { myOption.font.setBold(true); From 79d80bb6e7f15108798b828482d870d83a2f43e9 Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Sun, 7 Jan 2024 18:14:05 +0100 Subject: [PATCH 13/14] [UI] Fix bug with incomplete reset of the theme when clicking 'Cancel' in preference dialog --- src/dialogs/preferencedialog.cpp | 7 +++++++ src/dialogs/preferencedialog.h | 1 + 2 files changed, 8 insertions(+) diff --git a/src/dialogs/preferencedialog.cpp b/src/dialogs/preferencedialog.cpp index a5e70bc1..deae22b9 100644 --- a/src/dialogs/preferencedialog.cpp +++ b/src/dialogs/preferencedialog.cpp @@ -394,6 +394,11 @@ void PreferenceDialog::themeChanged() Theme::applyTheme(ui->themeWidget->theme()); } +void PreferenceDialog::resetTheme() +{ + Theme::applyTheme(m_settings->theme()); +} + /****************************************************************************** ******************************************************************************/ void PreferenceDialog::maxSimultaneousDownloadSlided(int value) @@ -471,6 +476,7 @@ void PreferenceDialog::restoreDefaultSettings() m_settings->endRestoreDefault(); resetLanguage(); + resetTheme(); } void PreferenceDialog::read() @@ -862,6 +868,7 @@ void PreferenceDialog::writeSettings() settings.endGroup(); resetLanguage(); + resetTheme(); } /****************************************************************************** diff --git a/src/dialogs/preferencedialog.h b/src/dialogs/preferencedialog.h index 4b188227..d190b588 100644 --- a/src/dialogs/preferencedialog.h +++ b/src/dialogs/preferencedialog.h @@ -59,6 +59,7 @@ private slots: void languageChanged(int value); void resetLanguage(); void themeChanged(); + void resetTheme(); void maxSimultaneousDownloadSlided(int value); void concurrentFragmentSlided(int value); From feb93f35b440ea4abf64801918249132b9d514e4 Mon Sep 17 00:00:00 2001 From: "SetVisible(0!=1)" Date: Sun, 7 Jan 2024 14:23:01 +0100 Subject: [PATCH 14/14] Update version --- version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version b/version index fcdb2e10..1454f6ed 100644 --- a/version +++ b/version @@ -1 +1 @@ -4.0.0 +4.0.1