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

Commit

Permalink
fix undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
theowenyoung committed Nov 7, 2022
1 parent d381f01 commit 3b72904
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/contentScript/enhance.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ function getNodesThatNeedToTranslate(root,ctx,options){
const contentContainer = getContainer(root,pageSpecialConfig);
if(contentContainer){
root = contentContainer;

}

for(const blockTag of blockElements){
Expand All @@ -308,7 +307,7 @@ function getNodesThatNeedToTranslate(root,ctx,options){
}
}
}
if(!pageSpecialConfig.containerSelector){
if(!pageSpecialConfig || !pageSpecialConfig.containerSelector){
// add addition heading nodes
for(const headingTag of headingElements){
const headings = originalRoot.querySelectorAll(headingTag.toLowerCase());
Expand Down
8 changes: 6 additions & 2 deletions src/contentScript/pageTranslator.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ function removeExtraDelimiter(textContext) {


function backgroundTranslateHTML(translationService, targetLanguage, sourceArray2d, dontSortResults) {
console.log('sourceArray2d', sourceArray2d)
return new Promise((resolve, reject) => {
chrome.runtime.sendMessage({
action: "translateHTML",
Expand Down Expand Up @@ -821,10 +820,15 @@ Promise.all([twpConfig.onReady(), getTabUrl()])
}

// piecesToTranslate = getPiecesToTranslate()
try{

piecesToTranslate = getNodesThatNeedToTranslate(document.body,ctx).reduce((acc, node) => {
return acc.concat(getPiecesToTranslate(node))
}, [])
console.log("test")
}catch(e){
console.error('get pieces failed',e)
throw e;
}
attributesToTranslate = getAttributesToTranslate()
// TODO
// attributesToTranslate = [];
Expand Down

0 comments on commit 3b72904

Please sign in to comment.