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

diff --git a/src/popup/detect-pdf.js b/src/popup/detect-pdf.js index 94ab4971..124e1c5b 100644 --- a/src/popup/detect-pdf.js +++ b/src/popup/detect-pdf.js @@ -1,9 +1,3 @@ -chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { - if (tabs[0].url.toLowerCase().endsWith(".pdf")) { - window.location = "popup-translate-document.html"; - } -}); - chrome.runtime.sendMessage({ action: "getTabMimeType" }, (mimeType) => { checkedLastError(); diff --git a/src/popup/old-popup.html b/src/popup/old-popup.html index 6a45062a..6e61ee74 100644 --- a/src/popup/old-popup.html +++ b/src/popup/old-popup.html @@ -100,6 +100,7 @@ +
translate.google.com
+
+ deepl.com +
+
+ onlinedoctranslator.com +
diff --git a/src/popup/popup.js b/src/popup/popup.js index 7b701efe..c21e62e3 100644 --- a/src/popup/popup.js +++ b/src/popup/popup.js @@ -630,6 +630,11 @@ twpConfig.onReady().then(() => twpI18n.updateUiMessages()).then(() => { url: chrome.runtime.getURL("/options/options.html#donation"), }); break; + case "translatePDF": + chrome.tabs.create({ + url: "https://pdf.translatewebpages.org/", + }); + break; default: break; }