Skip to content

Commit

Permalink
Versão 9.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
FilipePS committed Apr 24, 2023
1 parent 9df71a9 commit f153c1a
Show file tree
Hide file tree
Showing 13 changed files with 110 additions and 45 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ meta.txt
meta2.txt
result
*.zip
Traduzir-paginas-web.pem
10 changes: 10 additions & 0 deletions dist/chromium/twp-registry-install.reg
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 10 additions & 0 deletions dist/chromium/twp-registry-uninstall-all.reg
Original file line number Diff line number Diff line change
@@ -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]

10 changes: 10 additions & 0 deletions dist/chromium/twp-registry-uninstall-self.reg
Original file line number Diff line number Diff line change
@@ -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"=-
6 changes: 6 additions & 0 deletions dist/chromium/updates.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='bolggfoncklhniejomgplkjcllmnonbh'>
<updatecheck codebase='https://github.com/FilipePS/Traduzir-paginas-web/releases/download/v9.7.2/TWP_9.7.2_Chromium.crx' version='9.7.2' status='ok' />
</app>
</gupdate>
15 changes: 15 additions & 0 deletions dist/firefox/updates.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
}
}
70 changes: 38 additions & 32 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -31,7 +31,7 @@ const babelConfig = {
"@babel/preset-env",
{
targets: {
firefox: "63",
firefox: "64",
chrome: "70",
},
// corejs: 3,
Expand All @@ -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);
}),
]);
Expand All @@ -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,
});
Expand All @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand All @@ -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"
}
Expand Down
15 changes: 8 additions & 7 deletions src/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -182,7 +182,9 @@ chrome.runtime.onInstalled.addListener((details) => {
url: chrome.runtime.getURL("/options/options.html#release_notes"),
});
}
});

twpConfig.onReady(async () => {
translationCache.deleteTranslationCache();
});
}
Expand Down Expand Up @@ -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) => {});
4 changes: 2 additions & 2 deletions src/chrome_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
6 changes: 6 additions & 0 deletions src/options/release-notes/en.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ <h5>
</section>

<section>
<h4>9.7.2</h4>
<ul>
<li>Added option to disable persistent translation cache (on-disk cache).
<ul><li>By default, persistent caching will be disabled.</li></ul>
</li>
</ul>
<h4>9.7</h4>
<ul>
<li>Added:
Expand Down
2 changes: 1 addition & 1 deletion updates.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version='1.0' encoding='UTF-8'?>
<gupdate xmlns='http://www.google.com/update2/response' protocol='2.0'>
<app appid='bolggfoncklhniejomgplkjcllmnonbh'>
<updatecheck codebase='https://github.com/FilipePS/Traduzir-paginas-web/releases/download/v9.7.0.3/TWP.9.7.0.3.crx' version='9.7.0.3' status='ok' />
<updatecheck codebase='https://github.com/FilipePS/Traduzir-paginas-web/releases/download/v9.7.2/TWP_9.7.2_Chromium.crx' version='9.7.2' status='ok' />
</app>
</gupdate>

0 comments on commit f153c1a

Please sign in to comment.