@@ -13,34 +13,50 @@ export default {
1313
1414 popupScript : {
1515 onClick : async ( ) => {
16- const { getCurrentTab } = await import ( "./helpers/utils.js" ) ;
16+ const { t } = await import ( "../popup/helpers/lang.js" ) ;
17+ const { getCurrentTab, openWebAndRunScript } = await import (
18+ "./helpers/utils.js"
19+ ) ;
1720 let tab = await getCurrentTab ( ) ;
1821 let { url, title } = tab ;
1922
23+ let guide = t ( {
24+ vi : "Sử dụng chức năng\nTự động > In web ra PDF hoặc\nTự động > Chụp ảnh toàn bộ web\nđể tải slides nhé." ,
25+ en : "Please use feature\nAutomation > Screenshot full page OR\nAutomation > Web to PDF\nto download this slides" ,
26+ } ) ;
27+
2028 if ( url . includes ( "/htmlpresent" ) ) {
21- alert (
22- "Ban hãy bấm Ctrl+S để lưu toàn bộ slides trong trang hiện tại nhé."
23- ) ;
29+ alert ( guide ) ;
2430 } else {
2531 url = prompt (
26- "Nhập link file powerpoint (slide) google drive: \nĐịnh dạng: https://docs.google.com/presentation/*" ,
32+ t ( {
33+ vi : "Nhập link file powerpoint (slide) google drive: \nĐịnh dạng: https://docs.google.com/presentation/*" ,
34+ en : "Enter google drive presentation url: \nFormat: https://docs.google.com/presentation/*" ,
35+ } ) ,
2736 url
2837 ) ;
2938 if ( ! url ) return ;
3039
3140 let id = / d \/ ( [ ^ \/ ] + ) \/ ? / . exec ( url ) ?. [ 1 ] ;
3241 if ( ! id ) {
33- alert ( "Không tìm được id file trên url" ) ;
42+ alert (
43+ t ( {
44+ vi : "Không tìm được id file trên url" ,
45+ en : "Can not find file id in url" ,
46+ } )
47+ ) ;
3448 return ;
3549 }
3650
37- alert (
38- "File sẽ được mở trong trang mới. Bạn có thể bấm Ctrl+S để lưu toàn bộ slides trong trang mới."
39- ) ;
40-
41- window . open (
42- "https://docs.google.com/presentation/d/" + id + "/htmlpresent"
43- ) ;
51+ openWebAndRunScript ( {
52+ url : "https://docs.google.com/presentation/d/" + id + "/htmlpresent" ,
53+ func : async ( guide ) => {
54+ window . onload = alert ( guide ) ;
55+ } ,
56+ args : [ guide ] ,
57+ focusImmediately : true ,
58+ waitUntilLoadEnd : false ,
59+ } ) ;
4460 }
4561 } ,
4662 } ,
0 commit comments