Skip to content

Commit

Permalink
update dist
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Jan 12, 2024
1 parent c27ab98 commit 0eae16c
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
6 changes: 3 additions & 3 deletions dist/ebook/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/>

<title>E-Book Reader</title>
<link rel="stylesheet" href="../styles/inject.css?v=1705062501" />
<link rel="stylesheet" href="../styles/inject.css?v=1705063545" />
<style>
:root {
--active-bg: rgba(0, 0, 0, 0.05);
Expand Down Expand Up @@ -388,8 +388,8 @@ <h1 id="side-bar-title"></h1>
</svg>
</button>
</div>
<script src="../libs/foliate-js/ebook.js?v=1705062501" type="module"></script>
<script src="./ebook-global.js?v=1705062501"></script>
<script src="../libs/foliate-js/ebook.js?v=1705063545" type="module"></script>
<script src="./ebook-global.js?v=1705063545"></script>
<script src="../content_script.js"></script>
</body>
</html>
6 changes: 3 additions & 3 deletions dist/ebook/make/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
content="default-src 'self' blob:; script-src * data: blob: 'unsafe-inline' 'unsafe-eval'; style-src 'self' blob: 'unsafe-inline'; img-src 'self' blob: data:; connect-src 'self' blob: data:; frame-src blob: data:; object-src blob: data:; form-action 'none';"
/>
<title>E-Book Maker</title>
<link rel="stylesheet" href="../../styles/inject.css?v=1705062501" />
<link rel="stylesheet" href="../../styles/inject.css?v=1705063545" />
<style>
:root {
--active-bg: rgba(0, 0, 0, 0.05);
Expand Down Expand Up @@ -572,8 +572,8 @@ <h1 class="notranslate">
<div id="chapters"></div>
</div>

<script src="../../libs/foliate-js/make.js?v=1705062501" type="module"></script>
<script src="../ebook-builder-global.js?v=1705062501"></script>
<script src="../../libs/foliate-js/make.js?v=1705063545" type="module"></script>
<script src="../ebook-builder-global.js?v=1705063545"></script>
<script src="../../content_script.js" type="module"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion dist/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ <h1 id="side-bar-title"></h1>
</svg>
</button>
</div>
<script src="./html.js?v=1705062501"></script>
<script src="./html.js?v=1705063545"></script>
<script src="../content_script.js"></script>
</body>
</html>
4 changes: 2 additions & 2 deletions dist/libs/foliate-js/make.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/libs/subtitle/subtitle.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(()=>{var di=Object.defineProperty;var pi=(e,t)=>{for(var r in t)di(e,r,{get:t[r],enumerable:!0})};var A={BUILD_TIME:"2024-01-12T12:27:08.000Z",VERSION:"1.1.4",PROD:"1",REDIRECT_URL:"https://dash.immersivetranslate.com/auth-done/",PROD_API:"1",BETA:"0",IMMERSIVE_TRANSLATE_INJECTED_CSS:`:root {
(()=>{var di=Object.defineProperty;var pi=(e,t)=>{for(var r in t)di(e,r,{get:t[r],enumerable:!0})};var A={BUILD_TIME:"2024-01-12T12:45:28.422Z",VERSION:"1.1.4",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;
Expand Down Expand Up @@ -4850,7 +4850,7 @@ select.text-gray-6 {
<div class="immersive-translate-popup-mount" id="mount"></div>
</div>
`,IMMERSIVE_TRANSLATE_VIDEO_SUBTITLE_INJECT:`(()=>{var u="imt-subtitle-inject",c=class{from;to;constructor(e,s){this.from=e,this.to=s}sendMessages(e){globalThis.postMessage({type:u,to:this.to,from:this.from,action:e.action,data:e.data,id:e.id||new Date().getTime(),isAsync:!1})}getRandomId(){return(new Date().getTime()+Math.random())*Math.random()}sendAsyncMessages({action:e,data:s}){return new Promise(t=>{let n=this.getRandomId();globalThis.postMessage({type:u,to:this.to,from:this.from,action:e,data:s,id:n,isAsync:!0});let a=({data:o})=>{u===o.type&&o.id===n&&o.to===this.from&&(t(o.data),globalThis.removeEventListener("message",a))};globalThis.addEventListener("message",a)})}handleMessageOnce(e){return new Promise(s=>{let t=({data:n})=>{u===n.type&&n.action===e&&n.to===this.from&&(s(n.data),globalThis.removeEventListener("message",t))};globalThis.addEventListener("message",t)})}handleMessage(e,s){let t=({data:n})=>{u===n.type&&n.action===e&&n.to===this.from&&s(n)};return globalThis.addEventListener("message",t),()=>{globalThis.removeEventListener("message",t)}}handleMessages(e){let s=({data:t})=>{u===t.type&&t.to===this.from&&e(t)};return globalThis.addEventListener("message",s),()=>{globalThis.removeEventListener("message",s)}}},v=new c("content-script","inject"),l=new c("inject","content-script"),S={get(r,e,s){return e in r?(...t)=>{let n=r[e];return typeof n=="function"?n.apply(r,t):Reflect.get(r,e,s)}:t=>r.sendAsyncMessages({action:e,data:t})}},M=new Proxy(l,S),P=new Proxy(v,S);var i=class{content=M;config;constructor(e){this.config=e,l.handleMessages(async({action:s,id:t,data:n})=>{let a=this[s];if(!a)return;let o=a.apply(this,[n]);o instanceof Promise&&(o=await o),l.sendMessages({id:t,data:o})})}triggerSubtitle(e){}async translateSubtitle(e){let s=await this.content.requestSubtitle({url:e._url});if(s){if(this.config.responseType=="document"){let n=new DOMParser().parseFromString(s,"text/xml");Object.defineProperty(e,"responseXML",{value:n,writable:!1}),Object.defineProperty(e,"response",{value:n,writable:!1});return}let t;e.responseType=="arraybuffer"||this.config.responseType=="arraybuffer"?t=new TextEncoder().encode(s).buffer:t=s,Object.defineProperty(e,"responseText",{value:t,writable:!1}),Object.defineProperty(e,"response",{value:t,writable:!1})}}translateSubtitleWithFetch(e){return this.content.requestSubtitle({fetchInfo:e})}async getVideoMeta(e){}isSubtitleRequest(e){return!this.config||!this.config.subtitleUrlRegExp||!e?!1:new RegExp(this.config.subtitleUrlRegExp).test(e||"")}};var d=class extends i{timer=null;triggerSubtitle({force:e}){setTimeout(()=>{if(this.config?.subtitleButtonSelector){let s=document.querySelector(this.config.subtitleButtonSelector);if(s){let t=s.getAttribute("aria-pressed")==="true";t&&e?(s.click(),setTimeout(()=>{s.click()},100)):t||s.click();return}}if(this.config?.videoPlayerSelector){let s=document.querySelector(this.config.videoPlayerSelector);s.toggleSubtitles(),setTimeout(()=>{s.toggleSubtitles()},100)}},1e3)}async getVideoMeta(){if(!this.config.videoPlayerSelector)return null;try{return await this.sleep(100),document.querySelector(this.config.videoPlayerSelector)?.getPlayerResponse()}catch{return null}}sleep(e){return new Promise(s=>{setTimeout(()=>{s(null)},e)})}};var g=class extends i{timer=null;videoMeta={};constructor(e){super(e),this.hookJSON()}hookJSON(){let e=JSON.parse;JSON.parse=s=>{let t=e(s);try{t&&t.result&&t.result.timedtexttracks&&t.result.movieId&&(this.videoMeta[t.result.movieId]=t.result)}catch(n){console.log(n)}return t}}getVideoMeta(e){return this.videoMeta[e]}};var f=class extends i{timer=null;videoMeta={};constructor(e){super(e),this.hookJSON()}hookJSON(){let e=JSON.parse;JSON.parse=s=>{let t=e(s);try{t?.asset?.captions?.length?this.videoMeta[t.id]=t?.asset:t?.previews&&t?.course&&t?.previews?.forEach(n=>{this.videoMeta[n.id]=n})}catch(n){console.error(n)}return t}}getVideoMeta(e){return this.videoMeta[e]}};var m=class extends i{timer=null;videoMeta={};constructor(e){super(e),this.hookJSON()}hookJSON(){let e=JSON.parse;JSON.parse=s=>{let t=e(s);try{if(t?.stream?.sources?.length&&t?.stream?.sources[0]?.complete?.url){let n=window.location.pathname.split("/");n.length>2&&n[n.length-2]==="video"&&(this.videoMeta[n[n.length-1]]=t.stream.sources[0].complete.url)}}catch(n){console.error(n)}return t}}getVideoMeta(e){return this.videoMeta[e]}};async function R(){let r=await l.sendAsyncMessages({action:"getConfig"});if(!r)return;let s={youtube:d,netflix:g,webvtt:i,khanacademy:i,bilibili:i,udemy:f,general:i,ebutt:i,disneyplus:m}[r.type||""];if(!s)return;let t=new s(r);x(t,r)}p();R();function x(r,e){if(e.hookType==="xhr"){let s=XMLHttpRequest.prototype.open,t=XMLHttpRequest.prototype.send,n=function(){return this._url=arguments[1],s.apply(this,arguments)},a=async function(){return r.isSubtitleRequest(this._url)?(await p(),await r.translateSubtitle(this),t.apply(this,arguments)):t.apply(this,arguments)};Object.defineProperty(XMLHttpRequest.prototype,"open",{value:n,writable:!0}),Object.defineProperty(XMLHttpRequest.prototype,"send",{value:a,writable:!0})}else if(e.hookType==="fetch"){let s=globalThis.fetch;globalThis.fetch=async function(t,n){let a=typeof t=="string"?t:t.url||t.href;if(!r.isSubtitleRequest(a))return s(t,n);await p();let h;typeof t=="string"?h={url:t,method:"GET",headers:{}}:h=await T(t);let b=await r.translateSubtitleWithFetch(JSON.stringify({input:h,options:n}));return b?new Response(b):s(t,n)}}}var y=!1;async function p(){return y||(await l.handleMessageOnce("contentReady"),y=!0),y}function T(r){if(r instanceof URL)return{url:r.href,method:"GET",headers:{}};let e={url:r.url,method:r.method,headers:Object.fromEntries(r.headers.entries())};if(r.body)if(r.body instanceof FormData){let s={};for(let[t,n]of r.body.entries())s[t]=n;e.body=s}else return r.text().then(s=>(e.body=s,e));return Promise.resolve(e)}})();
`,OPTIONS_URL:"https://dash.immersivetranslate.com/",SHARE_DRAFT_URL:"https://immersivetranslate.com/preview",ASSETS_BASE_URL:"https://app.immersivetranslate.com/global-assets/",EBOOK_VIEWER_URL:"https://app.immersivetranslate.com/ebook/",EBOOK_BUILDER_URL:"https://app.immersivetranslate.com/ebook/make/",SUBTITLE_BUILDER_URL:"https://app.immersivetranslate.com/subtitle/",HTML_VIEWER_URL:"https://app.immersivetranslate.com/html/",PDF_VIEWER_URL:"https://app.immersivetranslate.com/pdf/",TRANSLATE_FILE_URL:"https://app.immersivetranslate.com/",MOCK:"0",DEBUG:"0",IMMERSIVE_TRANSLATE_USERSCRIPT:"1",INSTALL_FROM:"official_userscript"};var wn=class{name;helper;build;detect;parse;constructor({name:t,build:r,detect:n,helper:a,parse:o}){this.name=t,this.helper=a,this.build=r,this.detect=i=>{if(typeof i!="string")throw new Error("Expected string content!");return n(i)},this.parse=(i,c)=>{if(typeof i!="string")throw new Error("Expected string content!");return o(i,c)}}},Ae=e=>new wn(e);var mi="ssa",mt={toMilliseconds:e=>{let t=/^\s*(\d+:)?(\d{1,2}):(\d{1,2})(?:[.,](\d{1,3}))?\s*$/.exec(e);if(!t)throw new Error(`Invalid time format: ${e}`);let r=t[1]?parseInt(t[1].replace(":","")):0,n=parseInt(t[2]),a=parseInt(t[3]),o=t[4]?parseInt(t[4]):0;return r*3600*1e3+n*60*1e3+a*1e3+o*10},toTimeString:e=>{let t=Math.floor(e/1e3/3600),r=Math.floor(e/1e3/60%60),n=Math.floor(e/1e3%60),a=Math.floor(e%1e3/10);return`${t}:${r<10?"0":""}${r}:${n<10?"0":""}${n}.${a<10?"0":""}${a}`}},Sn=(e,t)=>{let r,n=null,a=[],o=t.eol||`\r
`,OPTIONS_URL:"https://dash.immersivetranslate.com/",SHARE_DRAFT_URL:"https://immersivetranslate.com/preview",ASSETS_BASE_URL:"https://app.immersivetranslate.com/global-assets/",EBOOK_VIEWER_URL:"https://app.immersivetranslate.com/ebook/",EBOOK_BUILDER_URL:"https://app.immersivetranslate.com/ebook/make/",SUBTITLE_BUILDER_URL:"https://app.immersivetranslate.com/subtitle/",HTML_VIEWER_URL:"https://app.immersivetranslate.com/html/",PDF_VIEWER_URL:"https://app.immersivetranslate.com/pdf/",TRANSLATE_FILE_URL:"https://app.immersivetranslate.com/",MOCK:"0",DEBUG:"0",IMMERSIVE_TRANSLATE_USERSCRIPT:"1",INSTALL_FROM:"dev"};var wn=class{name;helper;build;detect;parse;constructor({name:t,build:r,detect:n,helper:a,parse:o}){this.name=t,this.helper=a,this.build=r,this.detect=i=>{if(typeof i!="string")throw new Error("Expected string content!");return n(i)},this.parse=(i,c)=>{if(typeof i!="string")throw new Error("Expected string content!");return o(i,c)}}},Ae=e=>new wn(e);var mi="ssa",mt={toMilliseconds:e=>{let t=/^\s*(\d+:)?(\d{1,2}):(\d{1,2})(?:[.,](\d{1,3}))?\s*$/.exec(e);if(!t)throw new Error(`Invalid time format: ${e}`);let r=t[1]?parseInt(t[1].replace(":","")):0,n=parseInt(t[2]),a=parseInt(t[3]),o=t[4]?parseInt(t[4]):0;return r*3600*1e3+n*60*1e3+a*1e3+o*10},toTimeString:e=>{let t=Math.floor(e/1e3/3600),r=Math.floor(e/1e3/60%60),n=Math.floor(e/1e3%60),a=Math.floor(e%1e3/10);return`${t}:${r<10?"0":""}${r}:${n<10?"0":""}${n}.${a<10?"0":""}${a}`}},Sn=(e,t)=>{let r,n=null,a=[],o=t.eol||`\r
`,i=e.split(/\r?\n\s*\n/);for(let c=0;c<i.length;c++){let s=/^\s*\[([^\]]+)\]\r?\n([\s\S]*)$/.exec(i[c]);if(s){let u=s[1],m=s[2].split(/\r?\n/);for(let p=0;p<m.length;p++){let g=m[p];if(/^\s*;/.test(g))continue;let h=/^\s*([^\s:]+):\s*(.*)$/.exec(g);if(h){if(u==="Script Info")if(r||(r={},r.type="meta",r.data={},a.push(r)),typeof r.data=="object"){let L=h[1].trim(),_=h[2].trim();r.data[L]=_}else throw new Error(`Invalid meta data: ${g}`);else if(u==="V4 Styles"||u==="V4+ Styles"){let L=h[1].trim(),_=h[2].trim();if(L==="Format")n=_.split(/\s*,\s*/g);else if(L==="Style"&&n){let f=_.split(/\s*,\s*/g),x={};x.type="style",x.data={};for(let k=0;k<n.length&&k<f.length;k++)x.data[n[k]]=f[k];a.push(x)}}else if(u==="Events"){let L=h[1].trim(),_=h[2].trim();if(L==="Format")n=_.split(/\s*,\s*/g);else if(L==="Dialogue"&&n){let f=_.split(/\s*,\s*/g),x={};x.type="caption",x.data={};for(let D=0;D<n.length&&D<f.length;D++)x.data[n[D]]=f[D];x.start=mt.toMilliseconds(x.data.Start),x.end=mt.toMilliseconds(x.data.End),x.duration=x.end-x.start,x.content=x.data.Text;let K=((D,U,S)=>D.split(U,S).join(U).length)(_,",",n.length-1)+1;x.content=_.substring(K),x.data.Text=x.content,x.text=x.content.replace(/\\N/g,o).replace(/\{[^}]+\}/g,""),a.push(x)}}}}}t.verbose}return a},_n=(e,t)=>{let r=t.eol||`\r
`,n=t.format==="ass",a="";a+=`[Script Info]${r}`,a+=`; Script generated by subsrt ${r}`,a+=`ScriptType: v4.00${n?"+":""}${r}`,a+=`Collisions: Normal${r}`,a+=r,n?(a+=`[V4+ Styles]${r}`,a+=`Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding${r}`,a+=`Style: DefaultVCD, Arial,28,&H00B4FCFC,&H00B4FCFC,&H00000008,&H80000008,-1,0,0,0,100,100,0.00,0.00,1,1.00,2.00,2,30,30,30,0${r}`):(a+=`[V4 Styles]${r}`,a+=`Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, TertiaryColour, BackColour, Bold, Italic, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, AlphaLevel, Encoding${r}`,a+=`Style: DefaultVCD, Arial,28,11861244,11861244,11861244,-2147483640,-1,0,1,1,2,2,30,30,30,0,0${r}`),a+=r,a+=`[Events]${r}`,a+=`Format: ${n?"Layer":"Marked"}, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text${r}`;for(let o=0;o<e.length;o++){let i=e[o];if(i.type!=="meta"){if(!i.type||i.type==="caption"){a+=`Dialogue: ${n?"0":"Marked=0"},${mt.toTimeString(i.start)},${mt.toTimeString(i.end)},DefaultVCD, NTP,0000,0000,0000,,${i.text.replace(/\r?\n/g,"\\N")}${r}`;continue}t.verbose}}return a},An=e=>/^\s*\[Script Info\]\r?\n/.test(e)&&/\s*\[Events\]\r?\n/.test(e)?e.indexOf("[V4+ Styles]")>0?"ass":"ssa":!1,Hr=Ae({name:mi,build:_n,detect:An,helper:mt,parse:Sn});var fi="ass",Kr=Ae({name:fi,build:_n,detect:An,helper:mt,parse:Sn});var hi="json",bi=(e,t)=>JSON.parse(e),yi=(e,t)=>JSON.stringify(e,void 0,2),Ti=e=>{try{let t=JSON.parse(e);return Array.isArray(t)&&t.length>0&&typeof t[0]=="object"}catch{return!1}},jr=Ae({name:hi,build:yi,detect:Ti,parse:bi});var xi="lrc",kn={toMilliseconds:e=>{let t=/^\s*(\d+):(\d{1,2})(?:[.,](\d{1,3}))?\s*$/.exec(e);if(!t)throw new Error(`Invalid time format: ${e}`);let r=parseInt(t[1]),n=parseInt(t[2]),a=t[3]?parseInt(t[3]):0;return r*60*1e3+n*1e3+a*10},toTimeString:e=>{let t=Math.floor(e/1e3/60),r=Math.floor(e/1e3%60),n=Math.floor(e%1e3);return`${(t<10?"0":"")+t}:${r<10?"0":""}${r}.${n<100?"0":""}${n<10?"0":Math.floor(n/10)}`}},vi=(e,t)=>{let r=null,n=[],a=e.split(/\r?\n/);for(let o=0;o<a.length;o++){if(!a[o]||a[o].trim().length===0)continue;let c=/^\[(\d{1,2}:\d{1,2}(?:[.,]\d{1,3})?)\](.*)(?:\r?\n)*$/.exec(a[o]);if(c){let s={};s.type="caption",s.start=kn.toMilliseconds(c[1]),s.end=s.start+2e3,s.duration=s.end-s.start,s.content=c[2],s.text=s.content,n.push(s),r&&(r.end=s.start,r.duration=r.end-r.start),r=s;continue}let l=/^\[(\w+):([^\]]*)\](?:\r?\n)*$/.exec(a[o]);if(l){let s={};s.type="meta",s.tag=l[1],l[2]&&(s.data=l[2]),n.push(s);continue}t.verbose}return n},wi=(e,t)=>{let r="",n=!1,a=t.eol||`\r
`;for(let o=0;o<e.length;o++){let i=e[o];if(i.type==="meta"){i.tag&&i.data&&typeof i.data=="string"&&(r+=`[${i.tag}:${i.data.replace(/[\r\n]+/g," ")}]${a}`);continue}if(!i.type||i.type==="caption"){n||(r+=a,n=!0),r+=`[${kn.toTimeString(i.start)}]${i.text}${a}`;continue}t.verbose}return r},Si=e=>/\r?\n\[\d+:\d{1,2}(?:[.,]\d{1,3})?\].*\r?\n/.test(e),Gr=Ae({name:xi,build:wi,detect:Si,helper:kn,parse:vi});var _i="sbv",Lt={toMilliseconds:e=>{let t=/^\s*(\d{1,2}):(\d{1,2}):(\d{1,2})(?:[.,](\d{1,3}))?\s*$/.exec(e);if(!t)throw new Error(`Invalid time format: ${e}`);let r=parseInt(t[1]),n=parseInt(t[2]),a=parseInt(t[3]),o=t[4]?parseInt(t[4]):0;return r*3600*1e3+n*60*1e3+a*1e3+o},toTimeString:e=>{let t=Math.floor(e/1e3/3600),r=Math.floor(e/1e3/60%60),n=Math.floor(e/1e3%60),a=Math.floor(e%1e3);return`${(t<10?"0":"")+t}:${r<10?"0":""}${r}:${n<10?"0":""}${n}.${a<100?"0":""}${a<10?"0":""}${a}`}},Ai=(e,t)=>{let r=[],n=t.eol||`\r
Expand Down
Loading

0 comments on commit 0eae16c

Please sign in to comment.