Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/chrome_manifest.json
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
"default_locale": "en",
"name": "Immersive Translate - 沉浸式翻译",
"description": "支持整页翻译·双语显示·只翻译正文。布局全面优化,和浏览器阅读模式类似,对Twitter, Reddit等网站做了定制优化",
"version": "0.0.5",
"version": "0.0.6",
"homepage_url": "https://github.com/theowenyoung/Traduzir-paginas-web",

"commands": {
15 changes: 15 additions & 0 deletions src/contentScript/enhance.js
Original file line number Diff line number Diff line change
@@ -227,11 +227,26 @@ function getNodesThatNeedToTranslate(root,hostname,options){
// all block nodes, nodes should have a order from top to bottom
let allNodes = [];

let currentTargetLanguage = twpConfig.get("targetLanguage")

// check sites
if(allBlocksSelectors.length>0){
for(const selector of allBlocksSelectors){
const nodes = root.querySelectorAll(selector);
for(const node of nodes){
if(hostname==="twitter.com"){
// check language
try{
const lang = node.getAttribute("lang");
if(lang && currentTargetLanguage.startsWith(lang)){
continue;
}
}catch(e){
// ignore
// console.log("e", e)
}
}

if(isValidNode(node)){
allNodes.push(node);
}
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
"default_locale": "en",
"name": "Immersive Translate - 沉浸式翻译",
"description": "支持整页翻译·双语显示·只翻译正文。布局全面优化,和浏览器阅读模式类似,对Twitter, Reddit等网站做了定制优化",
"version": "0.0.5",
"version": "0.0.6",
"homepage_url": "https://github.com/theowenyoung/Traduzir-paginas-web",

"browser_specific_settings": {

0 comments on commit 302c882

Please sign in to comment.