diff --git a/src/background/background.js b/src/background/background.js index 4599b59b..e8b31885 100644 --- a/src/background/background.js +++ b/src/background/background.js @@ -280,13 +280,18 @@ if (typeof chrome.contextMenus !== "undefined") { chrome.contextMenus.onClicked.addListener((info, tab) => { if (info.menuItemId == "translate-web-page") { - chrome.tabs.sendMessage( - tab.id, - { - action: "toggle-translation", - }, - checkedLastError - ); + const mimeType = tabToMimeType[tab.id]; + if (mimeType && mimeType.toLowerCase() === "application/pdf" && chrome.pageAction && chrome.pageAction.openPopup) { + chrome.pageAction.openPopup(); + } else { + chrome.tabs.sendMessage( + tab.id, + { + action: "toggle-translation", + }, + checkedLastError + ); + } } else if (info.menuItemId == "translate-selected-text") { if ( chrome.pageAction && diff --git a/src/contentScript/pageTranslator.js b/src/contentScript/pageTranslator.js index 21397b7e..e68da880 100644 --- a/src/contentScript/pageTranslator.js +++ b/src/contentScript/pageTranslator.js @@ -289,6 +289,13 @@ Promise.all([twpConfig.onReady(), getTabHostName()]).then(function (_) { const htmlTagsInlineIgnore = ["br", "code", "kbd", "wbr"]; // and input if type is submit or button, and
depending on settings const htmlTagsNoTranslate = ["title", "script", "style", "textarea", "svg"]; + if (location.hostname === "pdf.translatewebpages.org") { + const index = htmlTagsInlineText.indexOf("span"); + if (index !== -1) { + htmlTagsInlineText.splice(index, 1); + } + } + if (twpConfig.get("translateTag_pre") !== "yes") { htmlTagsInlineIgnore.push("pre"); } @@ -762,7 +769,7 @@ Promise.all([twpConfig.onReady(), getTabHostName()]).then(function (_) { } else { node.textContent = text; } - }; + } function translateResults(piecesToTranslateNow, results) { if (dontSortResults) { @@ -1199,7 +1206,11 @@ Promise.all([twpConfig.onReady(), getTabHostName()]).then(function (_) { if (result === "und") { originalTabLanguage = result; if ( - twpConfig.get("alwaysTranslateSites").indexOf(tabHostName) !== -1 + twpConfig.get("alwaysTranslateSites").indexOf(tabHostName) !== + -1 || + (location.hostname === "pdf.translatewebpages.org" && + twpConfig.get("neverTranslateSites").indexOf(tabHostName) === + -1) ) { pageTranslator.translatePage(); } @@ -1209,9 +1220,13 @@ Promise.all([twpConfig.onReady(), getTabHostName()]).then(function (_) { originalTabLanguage = langCode; } if ( - location.hostname === "translatewebpages.org" && - location.href.indexOf("?autotranslate") !== -1 && - twpConfig.get("neverTranslateSites").indexOf(tabHostName) === -1 + (location.hostname === "translatewebpages.org" && + location.href.indexOf("?autotranslate") !== -1 && + twpConfig.get("neverTranslateSites").indexOf(tabHostName) === + -1) || + (location.hostname === "pdf.translatewebpages.org" && + twpConfig.get("neverTranslateSites").indexOf(tabHostName) === + -1) ) { pageTranslator.translatePage(); } else { diff --git a/src/options/release-notes/en.html b/src/options/release-notes/en.html index 6a9e330f..27f606b4 100644 --- a/src/options/release-notes/en.html +++ b/src/options/release-notes/en.html @@ -29,6 +29,13 @@9.8 - June 1, 2023
Do not sort translation results
option is enabled