diff --git a/dist/ebook/index.html b/dist/ebook/index.html index d632cd4..78eda4c 100644 --- a/dist/ebook/index.html +++ b/dist/ebook/index.html @@ -11,7 +11,7 @@ /> E-Book Reader - + ${i}${o}`}async initContentViews(t){let n=t.sections,r=document.querySelector("#chapters"),i=t.resources,a=[];if(i&&i.guide&&i.guide.length)for(let d of i.guide)a.push(d.href);let s=(t.metadata||{}).title||"Unknown",l=document.querySelector("#bookTitle");l.textContent=s;let c=0,u=n.length;if(t.resources?.navPath){u+=1;let d=await t.loadText(t.resources.navPath);p(t.resources.navPath,d)}if(t.resources?.ncxPath){u+=1;let d=await t.loadText(t.resources.ncxPath),f=this.buildTocHtml(d);p(t.resources.ncxPath,f)}for(let d=0;d{if(c++,c===u){Ie("#progress").classList.add("none"),document.dispatchEvent(new CustomEvent("immersiveTranslateEbookLoaded"));let y=document.querySelectorAll("iframe"),w=0;y.forEach(_=>{let v=_.contentDocument;if(v){let x=v.body;if(x){let A=x.innerText.length;w+=A}}});let T=document.createElement("p");T.classList.add("notranslate"),T.innerText=`The book is about ${w} characters in total (\u672C\u4E66\u5927\u7EA6 ${w} \u4E2A\u5B57\u7B26)`,Ie("#stats").append(T)}}}}},hc=async e=>{document.body.removeChild(Ie("#drop-target"));let t=new fc;globalThis.reader=t,await t.open(e),Ie("#editor").classList.remove("none")},Q_=e=>e.preventDefault(),Z_=e=>{e.preventDefault();let t=Array.from(e.dataTransfer.items).find(n=>n.kind==="file");if(t){let n=t.webkitGetAsEntry();hc(n.isFile?t.getAsFile():n).catch(r=>{})}},dg=Ie("#drop-target");dg.addEventListener("drop",Z_);dg.addEventListener("dragover",Q_);Ie("#file-input").addEventListener("change",e=>hc(e.target.files[0]).catch(t=>{}));Ie("#file-button").addEventListener("click",()=>Ie("#file-input").click());function J_(){document.addEventListener(ig,e=>{let{detail:t}=e;if(t){let n=document.querySelector("#progress-number");try{let r=JSON.parse(t);if(r&&r.type&&r.payload){if(r.type==="paragraphTranslated"){let{ok:i}=r.payload;if(i?ro++:_r++,n&&no){let a=ro,o=ro+_r,s=a/no*100,l=Math.floor(s),c=Math.floor(o/no*100);if(l>100&&(l=100),c>100&&(c=100),window.dispatchEvent(new CustomEvent("immersive-translate-progress-change",{detail:{successProgress:l,totalProgress:c}})),n.innerText=`${l}%`,c===100&&_r>0){let u=document.querySelector("#error");u.innerHTML=mi.sanitize(`${_r} failed(\u5931\u8D25). Retry all (\u70B9\u6B64\u91CD\u8BD5\u5168\u90E8\u9519\u8BEF\u6BB5\u843D)`)}l===100&&(sg||(sg=!0,uc({particleCount:100,spread:160})))}}else if(r.type==="totalParagraphsCount")r.payload.totalParagraphsCount&&(no=r.payload.totalParagraphsCount);else if(r.type==="translateStart")ro=0,_r=0,window.dispatchEvent(new CustomEvent("immersive-translate-start-translate"));else if(r.type==="restorePage"){window.dispatchEvent(new CustomEvent("immersive-translate-reset-state"));let i=document.querySelector("#error"),a=document.querySelector("#progress-number");i&&(i.innerHTML=""),a&&(a.innerText="")}}}catch{}}})}function eT(){za.data("translationstatus",()=>({progresstxt:"\u5F00\u59CB\u7FFB\u8BD1(Translate)",state:"init",starttranslatebypopup:function(){this.state!=="started"&&(this.state="started",this.progresstxt="\u51C6\u5907\u4E2D...")},starttranslate:function(){if(this.state==="started")return;this.state="started",this.progresstxt="\u51C6\u5907\u4E2D...";let t=Ie("#translationMode").value;(!t||t!=="dual"&&t!=="translation")&&(t="dual"),document.dispatchEvent(new CustomEvent(dc,{detail:JSON.stringify({type:"translatePage",data:{translationMode:t}})}))},changeProgress(e){this.state="started",e&&e.detail&&e.detail.successProgress&&(this.progresstxt="\u5DF2\u7FFB\u8BD1 "+e.detail.successProgress+"%")},reset(){this.state="init",this.progresstxt="\u5F00\u59CB\u7FFB\u8BD1(Translate)"}})),za.start()}function tT(){Ie("#error").addEventListener("click",e=>{e.preventDefault();let t=document.querySelector("#error");for(;t.firstChild;)t.removeChild(t.firstChild);_r=0,document.dispatchEvent(new CustomEvent(dc,{detail:JSON.stringify({type:"retryFailedParagraphs"})}))})}function nT(){Ie("#open").addEventListener("click",()=>{window.location.reload()})}function rT(e,t){Ie("#export").addEventListener("click",async u=>{if(u.preventDefault(),!pn)return alert("Load failed");s();let p=pn.entries,d=new lg,f=new z_(d),b=new gi("application/epub+zip");await f.add("mimetype",b,{level:0,extendedTimestamp:!1});let g="";for(let m=0;m{let b=f.previousSibling;b&&(p.push(b.textContent.trim()),d.push(f.textContent.trim()),b.textContent=f.textContent.trim()+" - "+b.textContent.trim(),f.remove())}),{originalText:p.join(" "),translatedText:d.join(" "),text:u?.textContent?.trim()}}async function o({zipWriter:u,iframe:p,entry:d}){let f=p.contentDocument.cloneNode(!0);f.querySelectorAll("["+og+"]").forEach(T=>{$_&&delete T[ag];let _=Object.keys(T.dataset).filter(v=>v.startsWith(le));for(let v of _)delete T.dataset[v]}),f.querySelectorAll("[data-id]").forEach(T=>{T.removeAttribute("data-id")}),f.querySelectorAll("[contenteditable]").forEach(T=>{T.removeAttribute("contenteditable")}),f.querySelectorAll("style").forEach(T=>{T.getAttribute("type")||T.setAttribute("type","text/css")});let y=new XMLSerializer().serializeToString(f),w=new gi(y);try{await u.add(d.filename,w)}catch{}}function s(){document.querySelector("#export").classList.add("disabled");let p=document.querySelector("#exportAction");p&&p.classList.add("none");let d=document.querySelector("#exportStatus");d&&(d.innerText="Exporting..."),ug()}function l(){let u=document.querySelector("#export");u&&u.classList.remove("disabled"),exportAction&&exportAction.classList.remove("none"),exportStatus&&(exportStatus.textContent="")}async function c({zipWriter:u,zipFileWriter:p,finalTranslatedTitle:d}){await u.close();let f=await p.getData(),b="";d&&(b=d+"-"),b+=e.name,e.name.endsWith(".epub.zip")&&(b=b.replace(".epub.zip",".epub"));let g=b.lastIndexOf("."),m=Math.min(160,g);b=b.substring(0,m)+".epub",await li.saveAs(f,b)}}function iT(){Ie("#edit").addEventListener("click",e=>{e.preventDefault(),pn||alert("Load failed"),Y_()})}function aT(){setTimeout(()=>{let e=document.createElement("blockquote");e.classList.add("notranslate");let t=`

1. If the Epub contains images, it's fine for the edit box below not to show the images, the exported Epub will contain the images.
\u5982\u679C Epub \u91CC\u5305\u542B\u56FE\u7247\uFF0C\u4E0B\u9762\u7684\u7F16\u8F91\u6846\u4E0D\u663E\u793A\u56FE\u7247\u662F\u6B63\u5E38\u7684\uFF0C\u5BFC\u51FA\u540E\u7684 Epub \u91CC\u4F1A\u5305\u542B\u56FE\u7247\u3002

2. When the translation is finished, you can click the Edit button above to modify the translation.
\u7FFB\u8BD1\u5B8C\u6210\u540E\uFF0C\u4F60\u53EF\u4EE5\u70B9\u51FB\u4E0A\u65B9\u7684\u7F16\u8F91\u6309\u94AE\u6765\u4FEE\u6539\u8BD1\u6587\u3002

3. When there is a translation error, you can click Retry All above, or click Show Original and translate again. Or the whole page can be refreshed and started again, because the translated part is always cached and no further requests will be sent.
\u5F53\u51FA\u73B0\u7FFB\u8BD1\u9519\u8BEF\u65F6\uFF0C\u53EF\u4EE5\u70B9\u51FB\u4E0A\u65B9\u7684\u91CD\u8BD5\u5168\u90E8\uFF0C\u6216\u8005\u70B9\u51FB\u6D4F\u89C8\u5668\u6269\u5C55\u56FE\u6807\u5148\u663E\u793A\u539F\u6587\uFF0C\u518D\u7FFB\u8BD1\u3002\u6216\u8005\u6574\u4E2A\u5237\u65B0\u9875\u9762\u91CD\u65B0\u6765\u8FC7\u4E5F\u884C\uFF0C\u56E0\u4E3A\u5DF2\u7FFB\u8BD1\u7684\u90E8\u5206\u603B\u662F\u6709\u7F13\u5B58\u7684\uFF0C\u4E0D\u4F1A\u518D\u53D1\u51FA\u8BF7\u6C42\u3002`,n=!1;try{let a=document.querySelector("meta[name='immersive-translate-meta']");if(a){let o=Ul(a?.content||""),s=new TextDecoder().decode(o),l=JSON.parse(s);l&&l.isProUser&&(n=!0)}}catch{}n?t+=`

4. If you have additional needs, you can also purchase the Pro-only {{text}}`,optional:!0}]},transmart:{name:"Transmart",homepage:"https://transmart.qq.com/"},youdao:{name:"Youdao",homepage:"https://youdao.com/",docUrl:"https://immersivetranslate.com/docs/services/youdao/",allProps:[{name:"appId",required:!0,type:"text"},{name:"appSecret",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:200,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.domain",descriptionLink1:"https://fanyi.youdao.com/openapi/",type:"text",default:"general",optional:!0},{name:"vocabId",required:!1,labelKey:"field.vocabId",descriptionKey:"description.vocabId",type:"text",default:"",optional:!0}]},tencent:{name:"Tencent",homepage:"https://fanyi.qq.com/",docUrl:"https://immersivetranslate.com/docs/services/tencent/",allProps:[{name:"secretId",required:!0,type:"text"},{name:"secretKey",required:!0,type:"password"}]},aliyun:{name:"Aliyun",homepage:"https://translate.alibaba.com/",docUrl:"https://immersivetranslate.com/docs/services/aliyun/",allProps:[{name:"AccessKeyID",required:!0,type:"text"},{name:"AccessKeySecret",required:!0,type:"password"},{name:"scene",labelKey:"field.scene",descriptionKey:"description.scene",descriptionLink1:"https://help.aliyun.com/document_detail/158267.html",required:!1,optional:!0,type:"text",default:"general"}]},azure:{name:"azure",homepage:"https://learn.microsoft.com/en-us/azure/cognitive-services/translator/text-translation-overview",docUrl:"https://immersivetranslate.com/docs/services/azure/",allProps:[{name:"region",required:!1,default:"eastasia",type:"text"},{name:"APIKEY",required:!0,type:"password"},{name:"apiUrl",labelKey:"field.apiUrl",required:!1,type:"text",default:"https://api.cognitive.microsofttranslator.com/",descriptionKey:"description.azureApiUrl",optional:!0}]},papago:{name:"Papago",homepage:"https://translate.google.com/",canary:!0},baidu:{name:"Baidu",homepage:"https://fanyi.baidu.com/",docUrl:"https://immersivetranslate.com/docs/services/baidu/",allProps:[{name:"appid",required:!0,type:"text"},{name:"key",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:1,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0},{name:"action",required:!1,labelKey:"field.action",descriptionKey:"description.action",descriptionLink1:"https://fanyi-api.baidu.com/doc/21",type:"boolean",default:!1,optional:!0},{name:"domain",required:!1,labelKey:"field.domain",descriptionKey:"description.baiduField",descriptionLink1:"https://fanyi-api.baidu.com/doc/22",type:"text",default:"",optional:!0}]},volc:{name:"Volc",homepage:"https://www.volcengine.com/",docUrl:"https://immersivetranslate.com/docs/services/volcano/",allProps:[{name:"accessKeyId",required:!0,type:"text"},{name:"secretAccessKey",required:!0,type:"password"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1800,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:8,optional:!0}]},caiyun:{name:"Caiyun",homepage:"https://fanyi.caiyunapp.com/",docUrl:"https://immersivetranslate.com/docs/services/caiyun/",allProps:[{name:"token",required:!0,type:"password"}]},cai:{name:"Cai",homepage:"https://fanyi.caiyunapp.com/",alpha:!0},custom:{name:"Custom",beta:!0,homepage:"https://immersivetranslate.com/docs/services/custom/",titleKey:"description.custom",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"langs",required:!1,labelKey:"field.langs",type:"textarea",default:"zh-CN,en",optional:!0},{name:"placeholderDelimiters",required:!1,labelKey:"field.placeholderDelimiters",type:"text",default:P_,optional:!0},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},mock:{name:"Mock",homepage:"https://www.google.com"},mock2:{name:"Mock2",homepage:"https://www.google.com"},tenAlpha:{name:"TenAlpha",homepage:"https://fanyi.qq.com/",alpha:!0},you:{name:"You",alpha:!0,homepage:"https://youdao.com/"},openl:{name:"Openl",homepage:"https://openl.club/",docUrl:"https://immersivetranslate.com/docs/services/openL/",allProps:[...rg,{type:"password",name:"apikey",required:!0}],props:rg},volcAlpha:{name:"Volc Alpha",alpha:!0,homepage:"https://www.volcengine.com/"},d:{name:"D () ",canary:!0,homepage:"https://www.deepl.com/translator"},dpro:{name:"DPro (Canary) ",canary:!0,homepage:"https://www.deepl.com/translator"},deeplx:{name:"DeepLX (Beta)",beta:!0,homepage:"https://www.deepl.com/translator",allProps:[{name:"url",label:"API URL",required:!0,type:"text"},{name:"limit",required:!1,labelKey:"field.limitPerSecond",descriptionKey:"description.generalLimitPerSecond",type:"number",default:5,optional:!0},{name:"maxTextLengthPerRequest",required:!1,labelKey:"field.maxTextLengthPerRequest",descriptionKey:"description.maxTextLengthPerRequest",type:"number",default:1200,optional:!0},{name:"maxTextGroupLengthPerRequest",required:!1,labelKey:"field.maxTextGroupLengthPerRequest",descriptionKey:"description.maxTextGroupLengthPerRequest",type:"number",default:1,optional:!0}]},niu:{name:"niutrans",homepage:"https://niutrans.com/",docUrl:"https://immersivetranslate.com/docs/services/niu",allProps:[{name:"APIKEY",required:!0,type:"password"}]}},H5={type:le+"ChildFrameToRootFrameIdentifier"};var j5=hn()?"https://dash.immersivetranslate.com/#general":"http://localhost:8000/dist/userscript/options/#general";var q5=hn()||Mn()?"https://api2.immersivetranslate.com":"https://test-api2.immersivetranslate.com",R_=hn()||Mn()?"https://immersivetranslate.com/accounts/login?from=plugin":"https://test.immersivetranslate.com/accounts/login?from=plugin",K5=R_+"&utm_source=extension&utm_medium=extension&utm_campaign=error_modal",M_=hn()||Mn()?"https://immersivetranslate.com/profile":"https://test.immersivetranslate.com/profile",pc=hn()||Mn()?"https://immersivetranslate.com/pricing":"https://test.immersivetranslate.com/pricing",N_=hn()||Mn()?"https://immersivetranslate.com/topup?type=open_ai&":"https://test.immersivetranslate.com/topup?type=open_ai&",I_=hn()||Mn()?"https://immersivetranslate.com/topup?type=deepl&":"https://test.immersivetranslate.com/topup?type=deepl&",G5=pc+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_more",V5=pc+"?utm_source=extension&utm_medium=extension&utm_campaign=popup_footer",X5=pc+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Y5=N_+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Q5=I_+"utm_source=extension&utm_medium=extension&utm_campaign=error_modal",Z5=M_+"?utm_source=extension&utm_medium=extension&utm_campaign=error_modal&upgradeFromTrial=true";var{ZipReader:F_,BlobReader:io,TextReader:gi,TextWriter:B_,BlobWriter:lg,ZipWriter:z_}=hs;sa({useWebWorkers:!1});var U_=async e=>{let t=new Uint8Array(await e.slice(0,4).arrayBuffer());return t[0]===80&&t[1]===75&&t[2]===3&&t[3]===4},pn=null,no=0,ro=0,_r=0,sg=!1,W_=Cr(),$_=W_.PROD==="1",H_=async e=>{let n=await new F_(new io(e)).getEntries();e.name&&e.name.endsWith(".zip")&&n.every(c=>c.filename.startsWith(e.name.slice(0,-4)+"/"))&&(n=n.map(c=>(c.filename=c.filename.slice(e.name.length-3),c)));let r=new Map(n.map(l=>[l.filename,l])),i=l=>(c,...u)=>r.has(c)?l(r.get(c),...u):null,a=i(l=>l.getData(new B_)),o=i((l,c)=>l.getData(new lg(c)));return{entries:n,loadText:a,loadBlob:o,getSize:l=>r.get(l)?.uncompressedSize??0}},cg=async e=>e.isFile?e:(await Promise.all(Array.from(await new Promise((t,n)=>e.createReader().readEntries(r=>t(r),r=>n(r))),cg))).flat(),j_=async e=>{let t=await cg(e);t=t.map(p=>p);let n=[],r=await Promise.all(t.map(p=>new Promise((d,f)=>p.file(b=>d([b,p.fullPath]),b=>f(b))))),i=new Map(r.map(([p,d])=>{let f=d.replace(e.fullPath+"/","");return n.push({filename:f,...p}),[f,p]})),a=new TextDecoder,o=p=>p?a.decode(p):null,s=p=>i.get(p)?.arrayBuffer()??null;return{entries:n,loadText:async p=>o(await s(p)),loadBlob:async p=>i.get(p),getSize:p=>i.get(p)?.size??0}},q_=({name:e,type:t})=>t==="application/vnd.comicbook+zip"||e.endsWith(".cbz"),K_=({name:e,type:t})=>t==="application/x-fictionbook+xml"||e.endsWith(".fb2"),G_=({name:e,type:t})=>t==="application/x-zip-compressed-fb2"||e.endsWith(".fb2.zip")||e.endsWith(".fbz"),V_=async(e,t)=>{let n;if(e.isDirectory){let a=await j_(e);pn=a,n=await new Or(a).init()}else if(e.size)if(await U_(e)){let a=await H_(e);if(pn=a,q_(e))n=Wc(a,e);else if(G_(e)){let{entries:o}=a,s=o.find(c=>c.filename.endsWith(".fb2")),l=await a.loadBlob((s??o[0]).filename);n=await yo(l)}else n=await new Or(a).init()}else await Jc(e)?n=await new Fi({unzlib:Rp}).open(e):K_(e)&&(n=await yo(e));else throw new Error("File not found");if(!n)throw new Error("File type not supported");let r=new Di(n,t),i=await r.display();return document.body.append(i),r},Ie=document.querySelector.bind(document),Gn=!1;function ug(){let e=document.querySelectorAll("iframe");for(let r=0;r{Ie("#dimming-overlay").classList.add("show"),Ie("#side-bar").classList.add("show")}),Ie("#dimming-overlay").addEventListener("click",()=>this.closeSideBar());let t=zc([{name:"layout",label:"Layout",type:"radio",items:[["Paginated","paginated"],["Scrolled","scrolled"]],onclick:n=>{this.layout.flow=n}}]);t.element.classList.add("menu"),Ie("#menu-button").append(t.element),Ie("#menu-button > button").addEventListener("click",()=>t.element.classList.toggle("show")),t.groups.layout.select("paginated")}async open(t){Ie("#progress").classList.remove("none");try{this.view=await V_(t,this.#e.bind(this));let{book:n}=this.view;J_(),tT(),nT(),rT(t,n),iT(),eT(),await this.initContentViews(n),aT()}catch(n){alert(n.message),window.location.reload()}}#e(t){}buildTocHtml(t){let n=new DOMParser().parseFromString(t,"application/xhtml+xml"),i=n.querySelector("docTitle").outerHTML,o=n.querySelector("navMap").outerHTML;return`${i}${o}`}async initContentViews(t){let n=t.sections,r=document.querySelector("#chapters"),i=t.resources,a=[];if(i&&i.guide&&i.guide.length)for(let d of i.guide)a.push(d.href);let s=(t.metadata||{}).title||"Unknown",l=document.querySelector("#bookTitle");l.textContent=s;let c=0,u=n.length;if(t.resources?.navPath){u+=1;let d=await t.loadText(t.resources.navPath);p(t.resources.navPath,d)}if(t.resources?.ncxPath){u+=1;let d=await t.loadText(t.resources.ncxPath),f=this.buildTocHtml(d);p(t.resources.ncxPath,f)}for(let d=0;d{if(c++,c===u){Ie("#progress").classList.add("none"),document.dispatchEvent(new CustomEvent("immersiveTranslateEbookLoaded"));let y=document.querySelectorAll("iframe"),w=0;y.forEach(_=>{let v=_.contentDocument;if(v){let x=v.body;if(x){let A=x.innerText.length;w+=A}}});let T=document.createElement("p");T.classList.add("notranslate"),T.innerText=`The book is about ${w} characters in total (\u672C\u4E66\u5927\u7EA6 ${w} \u4E2A\u5B57\u7B26)`,Ie("#stats").append(T)}}}}},hc=async e=>{document.body.removeChild(Ie("#drop-target"));let t=new fc;globalThis.reader=t,await t.open(e),Ie("#editor").classList.remove("none")},Q_=e=>e.preventDefault(),Z_=e=>{e.preventDefault();let t=Array.from(e.dataTransfer.items).find(n=>n.kind==="file");if(t){let n=t.webkitGetAsEntry();hc(n.isFile?t.getAsFile():n).catch(r=>{})}},dg=Ie("#drop-target");dg.addEventListener("drop",Z_);dg.addEventListener("dragover",Q_);Ie("#file-input").addEventListener("change",e=>hc(e.target.files[0]).catch(t=>{}));Ie("#file-button").addEventListener("click",()=>Ie("#file-input").click());function J_(){document.addEventListener(ig,e=>{let{detail:t}=e;if(t){let n=document.querySelector("#progress-number");try{let r=JSON.parse(t);if(r&&r.type&&r.payload){if(r.type==="paragraphTranslated"){let{ok:i}=r.payload;if(i?ro++:_r++,n&&no){let a=ro,o=ro+_r,s=a/no*100,l=Math.floor(s),c=Math.floor(o/no*100);if(l>100&&(l=100),c>100&&(c=100),window.dispatchEvent(new CustomEvent("immersive-translate-progress-change",{detail:{successProgress:l,totalProgress:c}})),n.innerText=`${l}%`,c===100&&_r>0){let u=document.querySelector("#error");u.innerHTML=mi.sanitize(`${_r} failed(\u5931\u8D25). Retry all (\u70B9\u6B64\u91CD\u8BD5\u5168\u90E8\u9519\u8BEF\u6BB5\u843D)`)}l===100&&(sg||(sg=!0,uc({particleCount:100,spread:160})))}}else if(r.type==="totalParagraphsCount")r.payload.totalParagraphsCount&&(no=r.payload.totalParagraphsCount);else if(r.type==="translateStart")ro=0,_r=0,window.dispatchEvent(new CustomEvent("immersive-translate-start-translate"));else if(r.type==="restorePage"){window.dispatchEvent(new CustomEvent("immersive-translate-reset-state"));let i=document.querySelector("#error"),a=document.querySelector("#progress-number");i&&(i.innerHTML=""),a&&(a.innerText="")}}}catch{}}})}function eT(){za.data("translationstatus",()=>({progresstxt:"\u5F00\u59CB\u7FFB\u8BD1(Translate)",state:"init",starttranslatebypopup:function(){this.state!=="started"&&(this.state="started",this.progresstxt="\u51C6\u5907\u4E2D...")},starttranslate:function(){if(this.state==="started")return;this.state="started",this.progresstxt="\u51C6\u5907\u4E2D...";let t=Ie("#translationMode").value;(!t||t!=="dual"&&t!=="translation")&&(t="dual"),document.dispatchEvent(new CustomEvent(dc,{detail:JSON.stringify({type:"translatePage",data:{translationMode:t}})}))},changeProgress(e){this.state="started",e&&e.detail&&e.detail.successProgress&&(this.progresstxt="\u5DF2\u7FFB\u8BD1 "+e.detail.successProgress+"%")},reset(){this.state="init",this.progresstxt="\u5F00\u59CB\u7FFB\u8BD1(Translate)"}})),za.start()}function tT(){Ie("#error").addEventListener("click",e=>{e.preventDefault();let t=document.querySelector("#error");for(;t.firstChild;)t.removeChild(t.firstChild);_r=0,document.dispatchEvent(new CustomEvent(dc,{detail:JSON.stringify({type:"retryFailedParagraphs"})}))})}function nT(){Ie("#open").addEventListener("click",()=>{window.location.reload()})}function rT(e,t){Ie("#export").addEventListener("click",async u=>{if(u.preventDefault(),!pn)return alert("Load failed");s();let p=pn.entries,d=new lg,f=new z_(d),b=new gi("application/epub+zip");await f.add("mimetype",b,{level:0,extendedTimestamp:!1});let g="";for(let m=0;m{let b=f.previousSibling;b&&(p.push(b.textContent.trim()),d.push(f.textContent.trim()),b.textContent=f.textContent.trim()+" - "+b.textContent.trim(),f.remove())}),{originalText:p.join(" "),translatedText:d.join(" "),text:u?.textContent?.trim()}}async function o({zipWriter:u,iframe:p,entry:d}){let f=p.contentDocument.cloneNode(!0);f.querySelectorAll("["+og+"]").forEach(T=>{$_&&delete T[ag];let _=Object.keys(T.dataset).filter(v=>v.startsWith(le));for(let v of _)delete T.dataset[v]}),f.querySelectorAll("[data-id]").forEach(T=>{T.removeAttribute("data-id")}),f.querySelectorAll("[contenteditable]").forEach(T=>{T.removeAttribute("contenteditable")}),f.querySelectorAll("style").forEach(T=>{T.getAttribute("type")||T.setAttribute("type","text/css")});let y=new XMLSerializer().serializeToString(f),w=new gi(y);try{await u.add(d.filename,w)}catch{}}function s(){document.querySelector("#export").classList.add("disabled");let p=document.querySelector("#exportAction");p&&p.classList.add("none");let d=document.querySelector("#exportStatus");d&&(d.innerText="Exporting..."),ug()}function l(){let u=document.querySelector("#export");u&&u.classList.remove("disabled"),exportAction&&exportAction.classList.remove("none"),exportStatus&&(exportStatus.textContent="")}async function c({zipWriter:u,zipFileWriter:p,finalTranslatedTitle:d}){await u.close();let f=await p.getData(),b="";d&&(b=d+"-"),b+=e.name,e.name.endsWith(".epub.zip")&&(b=b.replace(".epub.zip",".epub"));let g=b.lastIndexOf("."),m=Math.min(160,g);b=b.substring(0,m)+".epub",await li.saveAs(f,b)}}function iT(){Ie("#edit").addEventListener("click",e=>{e.preventDefault(),pn||alert("Load failed"),Y_()})}function aT(){setTimeout(()=>{let e=document.createElement("blockquote");e.classList.add("notranslate");let t=`

1. If the Epub contains images, it's fine for the edit box below not to show the images, the exported Epub will contain the images.
\u5982\u679C Epub \u91CC\u5305\u542B\u56FE\u7247\uFF0C\u4E0B\u9762\u7684\u7F16\u8F91\u6846\u4E0D\u663E\u793A\u56FE\u7247\u662F\u6B63\u5E38\u7684\uFF0C\u5BFC\u51FA\u540E\u7684 Epub \u91CC\u4F1A\u5305\u542B\u56FE\u7247\u3002

2. When the translation is finished, you can click the Edit button above to modify the translation.
\u7FFB\u8BD1\u5B8C\u6210\u540E\uFF0C\u4F60\u53EF\u4EE5\u70B9\u51FB\u4E0A\u65B9\u7684\u7F16\u8F91\u6309\u94AE\u6765\u4FEE\u6539\u8BD1\u6587\u3002

3. When there is a translation error, you can click Retry All above, or click Show Original and translate again. Or the whole page can be refreshed and started again, because the translated part is always cached and no further requests will be sent.
\u5F53\u51FA\u73B0\u7FFB\u8BD1\u9519\u8BEF\u65F6\uFF0C\u53EF\u4EE5\u70B9\u51FB\u4E0A\u65B9\u7684\u91CD\u8BD5\u5168\u90E8\uFF0C\u6216\u8005\u70B9\u51FB\u6D4F\u89C8\u5668\u6269\u5C55\u56FE\u6807\u5148\u663E\u793A\u539F\u6587\uFF0C\u518D\u7FFB\u8BD1\u3002\u6216\u8005\u6574\u4E2A\u5237\u65B0\u9875\u9762\u91CD\u65B0\u6765\u8FC7\u4E5F\u884C\uFF0C\u56E0\u4E3A\u5DF2\u7FFB\u8BD1\u7684\u90E8\u5206\u603B\u662F\u6709\u7F13\u5B58\u7684\uFF0C\u4E0D\u4F1A\u518D\u53D1\u51FA\u8BF7\u6C42\u3002`,n=!1;try{let a=document.querySelector("meta[name='immersive-translate-meta']");if(a){let o=Ul(a?.content||""),s=new TextDecoder().decode(o),l=JSON.parse(s);l&&l.isProUser&&(n=!0)}}catch{}n?t+=`

4. If you have additional needs, you can also purchase the Pro-only
diff --git a/dist/libs/subtitle/subtitle.js b/dist/libs/subtitle/subtitle.js index 47aa36c..e188390 100644 --- a/dist/libs/subtitle/subtitle.js +++ b/dist/libs/subtitle/subtitle.js @@ -1,4 +1,4 @@ -(()=>{var ui=Object.defineProperty;var di=(e,t)=>{for(var r in t)ui(e,r,{get:t[r],enumerable:!0})};var A={BUILD_TIME:"2024-01-11T03:01:59.578Z",VERSION:"1.1.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { +(()=>{var ui=Object.defineProperty;var di=(e,t)=>{for(var r in t)ui(e,r,{get:t[r],enumerable:!0})};var A={BUILD_TIME:"2024-01-11T10:51:18.209Z",VERSION:"1.1.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { --immersive-translate-theme-underline-borderColor: #72ece9; --immersive-translate-theme-nativeUnderline-borderColor: #72ece9; --immersive-translate-theme-nativeDashed-borderColor: #72ece9; diff --git a/dist/pdf/immservie.js b/dist/pdf/immservie.js index 4803a94..b99f0a7 100644 --- a/dist/pdf/immservie.js +++ b/dist/pdf/immservie.js @@ -1,4 +1,4 @@ -(()=>{var k={BUILD_TIME:"2024-01-11T03:01:59.578Z",VERSION:"1.1.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { +(()=>{var k={BUILD_TIME:"2024-01-11T10:51:18.209Z",VERSION:"1.1.3",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root { --immersive-translate-theme-underline-borderColor: #72ece9; --immersive-translate-theme-nativeUnderline-borderColor: #72ece9; --immersive-translate-theme-nativeDashed-borderColor: #72ece9; diff --git a/dist/pdf/index.html b/dist/pdf/index.html index 204db44..9007d95 100644 --- a/dist/pdf/index.html +++ b/dist/pdf/index.html @@ -44,14 +44,14 @@ type="application/l10n" href="../pdf/locale/locale.properties" /> - + - - - - + + + + - + @@ -60,7 +60,7 @@ - +