From f153c1aab265e92a8e917dc066947f0697114658 Mon Sep 17 00:00:00 2001 From: FilipePS Date: Mon, 24 Apr 2023 20:25:40 -0300 Subject: [PATCH] =?UTF-8?q?Vers=C3=A3o=209.7.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - dist/chromium/twp-registry-install.reg | 10 +++ dist/chromium/twp-registry-uninstall-all.reg | 10 +++ dist/chromium/twp-registry-uninstall-self.reg | 10 +++ dist/chromium/updates.xml | 6 ++ dist/firefox/updates.json | 15 ++++ gulpfile.js | 70 ++++++++++--------- package.json | 2 + src/background/background.js | 15 ++-- src/chrome_manifest.json | 4 +- src/manifest.json | 4 +- src/options/release-notes/en.html | 6 ++ updates.xml | 2 +- 13 files changed, 110 insertions(+), 45 deletions(-) create mode 100644 dist/chromium/twp-registry-install.reg create mode 100644 dist/chromium/twp-registry-uninstall-all.reg create mode 100644 dist/chromium/twp-registry-uninstall-self.reg create mode 100644 dist/chromium/updates.xml create mode 100644 dist/firefox/updates.json diff --git a/.gitignore b/.gitignore index 89cee7c2..ce0dc476 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,3 @@ meta.txt meta2.txt result *.zip -Traduzir-paginas-web.pem \ No newline at end of file diff --git a/dist/chromium/twp-registry-install.reg b/dist/chromium/twp-registry-install.reg new file mode 100644 index 00000000..c05323dd --- /dev/null +++ b/dist/chromium/twp-registry-install.reg @@ -0,0 +1,10 @@ +Windows Registry Editor Version 5.00 + +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\BraveSoftware\Brave\ExtensionInstallAllowlist] +"1337"="bolggfoncklhniejomgplkjcllmnonbh" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallAllowlist] +"1337"="bolggfoncklhniejomgplkjcllmnonbh" + +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge\ExtensionInstallAllowlist] +"1337"="bolggfoncklhniejomgplkjcllmnonbh" diff --git a/dist/chromium/twp-registry-uninstall-all.reg b/dist/chromium/twp-registry-uninstall-all.reg new file mode 100644 index 00000000..dc5c6c29 --- /dev/null +++ b/dist/chromium/twp-registry-uninstall-all.reg @@ -0,0 +1,10 @@ +Windows Registry Editor Version 5.00 + +[-HKEY_LOCAL_MACHINE\SOFTWARE\Policies\BraveSoftware\Brave\ExtensionInstallAllowlist] + + +[-HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallAllowlist] + + +[-HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge\ExtensionInstallAllowlist] + diff --git a/dist/chromium/twp-registry-uninstall-self.reg b/dist/chromium/twp-registry-uninstall-self.reg new file mode 100644 index 00000000..8ba3ee34 --- /dev/null +++ b/dist/chromium/twp-registry-uninstall-self.reg @@ -0,0 +1,10 @@ +Windows Registry Editor Version 5.00 + +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\BraveSoftware\Brave\ExtensionInstallAllowlist] +"1337"=- + +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\ExtensionInstallAllowlist] +"1337"=- + +[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Edge\ExtensionInstallAllowlist] +"1337"=- diff --git a/dist/chromium/updates.xml b/dist/chromium/updates.xml new file mode 100644 index 00000000..d5cdd6d6 --- /dev/null +++ b/dist/chromium/updates.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/dist/firefox/updates.json b/dist/firefox/updates.json new file mode 100644 index 00000000..62976818 --- /dev/null +++ b/dist/firefox/updates.json @@ -0,0 +1,15 @@ +{ + "addons": { + "{036a55b4-5e72-4d05-a06c-cba2dfcc134a}": { + "updates": [ + { + "version": "9.7.2", + "browser_specific_settings": { + "gecko": { "strict_min_version": "64.0" } + }, + "update_link": "https://github.com/FilipePS/Traduzir-paginas-web/releases/download/v9.7.2/TWP.9.7.2.Firefox.xpi" + } + ] + } + } +} diff --git a/gulpfile.js b/gulpfile.js index 3f53d862..503f3f0c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -14,8 +14,8 @@ const version = JSON.parse( fs.readFileSync("src/manifest.json", "utf8") ).version; -const chrome_folder_name = `TWP.${version}.Chrome`; -const firefoxfolder_name = `TWP.${version}.Firefox`; +const chromium_folder_name = `TWP_${version}_Chromium`; +const firefox_folder_name = `TWP_${version}_Firefox`; const mappath = `../maps/${version}`; const mapconfig = remoteSourceMaps @@ -31,7 +31,7 @@ const babelConfig = { "@babel/preset-env", { targets: { - firefox: "63", + firefox: "64", chrome: "70", }, // corejs: 3, @@ -51,59 +51,59 @@ gulp.task("clean", (cb) => { }); gulp.task("firefox-copy", () => { - return gulp.src(["src/**/**"]).pipe(gulp.dest(`build/${firefoxfolder_name}`)); + return gulp.src(["src/**/**"]).pipe(gulp.dest(`build/${firefox_folder_name}`)); }); gulp.task("firefox-babel", () => { return Promise.all([ new Promise((resolve, reject) => { gulp - .src([`build/${firefoxfolder_name}/background/*.js`]) + .src([`build/${firefox_folder_name}/background/*.js`]) .pipe(sourcemaps.init()) .pipe(babel(babelConfig)) .pipe(sourcemaps.write(mappath, mapconfig)) .on("error", reject) - .pipe(gulp.dest(`build/${firefoxfolder_name}/background`)) + .pipe(gulp.dest(`build/${firefox_folder_name}/background`)) .on("end", resolve); }), new Promise((resolve, reject) => { gulp - .src([`build/${firefoxfolder_name}/lib/*.js`]) + .src([`build/${firefox_folder_name}/lib/*.js`]) .pipe(sourcemaps.init()) .pipe(babel(babelConfig)) .pipe(sourcemaps.write(mappath, mapconfig)) .on("error", reject) - .pipe(gulp.dest(`build/${firefoxfolder_name}/lib`)) + .pipe(gulp.dest(`build/${firefox_folder_name}/lib`)) .on("end", resolve); }), new Promise((resolve, reject) => { gulp - .src([`build/${firefoxfolder_name}/contentScript/*.js`]) + .src([`build/${firefox_folder_name}/contentScript/*.js`]) .pipe(sourcemaps.init()) .pipe(babel(babelConfig)) .pipe(sourcemaps.write(mappath, mapconfig)) .on("error", reject) - .pipe(gulp.dest(`build/${firefoxfolder_name}/contentScript`)) + .pipe(gulp.dest(`build/${firefox_folder_name}/contentScript`)) .on("end", resolve); }), new Promise((resolve, reject) => { gulp - .src([`build/${firefoxfolder_name}/options/*.js`]) + .src([`build/${firefox_folder_name}/options/*.js`]) .pipe(sourcemaps.init()) .pipe(babel(babelConfig)) .pipe(sourcemaps.write(mappath, mapconfig)) .on("error", reject) - .pipe(gulp.dest(`build/${firefoxfolder_name}/options`)) + .pipe(gulp.dest(`build/${firefox_folder_name}/options`)) .on("end", resolve); }), new Promise((resolve, reject) => { gulp - .src([`build/${firefoxfolder_name}/popup/*.js`]) + .src([`build/${firefox_folder_name}/popup/*.js`]) .pipe(sourcemaps.init()) .pipe(babel(babelConfig)) .pipe(sourcemaps.write(mappath, mapconfig)) .on("error", reject) - .pipe(gulp.dest(`build/${firefoxfolder_name}/popup`)) + .pipe(gulp.dest(`build/${firefox_folder_name}/popup`)) .on("end", resolve); }), ]); @@ -115,12 +115,12 @@ gulp.task("firefox-move-sourcemap", (cb) => { } return new Promise((resolve, reject) => { gulp - .src([`build/${firefoxfolder_name}/maps/**/*`]) + .src([`build/${firefox_folder_name}/maps/**/*`]) .pipe(gulp.dest("build/maps")) .on("error", reject) .on("end", resolve); }).then(() => { - fs.rmSync(`build/${firefoxfolder_name}/maps`, { + fs.rmSync(`build/${firefox_folder_name}/maps`, { recursive: true, force: true, }); @@ -129,43 +129,49 @@ gulp.task("firefox-move-sourcemap", (cb) => { gulp.task("firefox-zip", () => { return gulp - .src([`build/${firefoxfolder_name}/**/*`]) - .pipe(zip(`TWP.${version}.Firefox.zip`)) + .src([`build/${firefox_folder_name}/**/*`]) + .pipe(zip(`TWP_${version}_Firefox.zip`)) .pipe(gulp.dest("build")); }); gulp.task("chrome-copy-from-firefox", () => { return gulp - .src([`build/${firefoxfolder_name}/**/**`]) - .pipe(gulp.dest(`build/${chrome_folder_name}`)); + .src([`build/${firefox_folder_name}/**/**`]) + .pipe(gulp.dest(`build/${chromium_folder_name}`)); }); gulp.task("chrome-rename", (cb) => { fs.renameSync( - `build/${chrome_folder_name}/manifest.json`, - `build/${chrome_folder_name}/firefox_manifest.json` + `build/${chromium_folder_name}/manifest.json`, + `build/${chromium_folder_name}/firefox_manifest.json` ); fs.renameSync( - `build/${chrome_folder_name}/chrome_manifest.json`, - `build/${chrome_folder_name}/manifest.json` + `build/${chromium_folder_name}/chrome_manifest.json`, + `build/${chromium_folder_name}/manifest.json` ); cb(); }); gulp.task("chrome-zip", () => { return gulp - .src([`build/${chrome_folder_name}/**/**`]) - .pipe(zip(`TWP.${version}.Chrome.zip`)) + .src([`build/${chromium_folder_name}/**/**`]) + .pipe(zip(`TWP_${version}_Chrome.zip`)) .pipe(gulp.dest("build")); }); gulp.task("chrome-sign", (cb) => { - return crx3([`build/TWP.${version}.Chrome/manifest.json`], { - keyPath: "buld/Traduzir-paginas-web.pem", - crxPath: `build/TWP.${version}.Chrome.crx`, - }) - .then(() => console.log("done")) - .catch(console.error); + const dialog = require("node-file-dialog"); + + if (process.argv[2] === "--sign") { + return dialog({type: "open-file"}).then((file) => { + return crx3([`build/${chromium_folder_name}/manifest.json`], { + keyPath: file[0], + crxPath: `build/${chromium_folder_name}.crx`, + }) + }); + } else { + cb(); + } }); gulp.task( diff --git a/package.json b/package.json index 2cf60769..2f0fe1c7 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ "scripts": { "build": "npx gulp", "build:local-sourcemaps": "npx gulp --local-sourcemaps", + "build:sign": "npx gulp --sign", "polyfill": "npx webpack --entry=./polyfill.js --output-path=./src/lib --output-filename=polyfill.js -d inline-source-map" }, "dependencies": { @@ -22,6 +23,7 @@ "gulp-babel": "^8.0.0", "gulp-sourcemaps": "^3.0.0", "gulp-zip": "^5.1.0", + "node-file-dialog": "^1.0.3", "webpack": "^5.80.0", "webpack-cli": "^5.0.2" } diff --git a/src/background/background.js b/src/background/background.js index 0af0f8ca..9db503a3 100644 --- a/src/background/background.js +++ b/src/background/background.js @@ -141,17 +141,17 @@ chrome.runtime.onInstalled.addListener((details) => { }); twpConfig.onReady(async () => { if (chrome.i18n.getUILanguage() === "zh-CN") { - twpConfig.set("pageTranslatorService", "bing") - twpConfig.set("textTranslatorService", "bing") + twpConfig.set("pageTranslatorService", "bing"); + twpConfig.set("textTranslatorService", "bing"); } - }) + }); } else if ( details.reason == "update" && chrome.runtime.getManifest().version != details.previousVersion ) { twpConfig.onReady(async () => { if (platformInfo.isMobile.any) return; - if (twpConfig.get("showReleaseNotes") !== "yes") return; + // if (twpConfig.get("showReleaseNotes") !== "yes") return; let lastTimeShowingReleaseNotes = twpConfig.get( "lastTimeShowingReleaseNotes" @@ -182,7 +182,9 @@ chrome.runtime.onInstalled.addListener((details) => { url: chrome.runtime.getURL("/options/options.html#release_notes"), }); } + }); + twpConfig.onReady(async () => { translationCache.deleteTranslationCache(); }); } @@ -1016,6 +1018,5 @@ twpConfig.onReady(async () => { ); }); - -// garante que a extensão só seja atualizada quando reiniciar o navegador ao reiniciar manualmente a extensão. -chrome.runtime.onUpdateAvailable.addListener(details => {}); +// garante que a extensão só seja atualizada quando reiniciar o navegador ao reiniciar manualmente a extensão. +chrome.runtime.onUpdateAvailable.addListener((details) => {}); diff --git a/src/chrome_manifest.json b/src/chrome_manifest.json index 127dd0a9..0249c48f 100644 --- a/src/chrome_manifest.json +++ b/src/chrome_manifest.json @@ -3,9 +3,9 @@ "default_locale": "en", "name": "TWP - Translate Web Pages", "description": "__MSG_extensionDescription__", - "version": "9.7.0.6", + "version": "9.7.2", "homepage_url": "https://github.com/FilipePS/Traduzir-paginas-web", - "update_url": "https://raw.githubusercontent.com/FilipePS/Traduzir-paginas-web/master/updates.xml", + "update_url": "https://raw.githubusercontent.com/FilipePS/Traduzir-paginas-web/master/dist/chromium/updates.xml", "commands": { "hotkey-toggle-translation": { "suggested_key": { diff --git a/src/manifest.json b/src/manifest.json index 934bcbdc..3645d487 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -3,12 +3,12 @@ "default_locale": "en", "name": "TWP - Translate Web Pages", "description": "__MSG_extensionDescription__", - "version": "9.7.0.6", + "version": "9.7.2", "homepage_url": "https://github.com/FilipePS/Traduzir-paginas-web", "browser_specific_settings": { "gecko": { "id": "{036a55b4-5e72-4d05-a06c-cba2dfcc134a}", - "strict_min_version": "63.0" + "strict_min_version": "64.0" } }, "commands": { diff --git a/src/options/release-notes/en.html b/src/options/release-notes/en.html index 36113f54..693294b5 100644 --- a/src/options/release-notes/en.html +++ b/src/options/release-notes/en.html @@ -23,6 +23,12 @@
+

9.7.2

+
    +
  • Added option to disable persistent translation cache (on-disk cache). +
    • By default, persistent caching will be disabled.
    +
  • +

9.7

  • Added: diff --git a/updates.xml b/updates.xml index 34d51bb6..d5cdd6d6 100644 --- a/updates.xml +++ b/updates.xml @@ -1,6 +1,6 @@ - +