@@ -1013,6 +1013,43 @@ function initScrollToTop() {
10131013 // });
10141014}
10151015
1016+ async function initShowDonate ( ) {
1017+ const clickedDonate = await Storage . get ( "clickedDonate" ) ;
1018+ let count = ( await Storage . get ( "openPopupCount" ) ) || 0 ;
1019+ count ++ ;
1020+ Storage . set ( "openPopupCount" , count ) ;
1021+ if ( ! clickedDonate && count > 0 && count % 10 === 0 ) {
1022+ const res = await Swal . fire ( {
1023+ icon : "info" ,
1024+ title : t ( {
1025+ vi : "Cảm ơn bạn tin dùng" ,
1026+ en : "Thanks for using Useful-scripts" ,
1027+ } ) ,
1028+ text : t ( {
1029+ vi : "Useful-scripts là miễn phí. Nhưng nếu bạn thích nó, bạn có thể hỗ trợ mình 1 ly cà phê. Một đồng cũng đáng quý 💓" ,
1030+ en : "It's free. But you can support me if you like. I'll appreciate if you give me some love 💓" ,
1031+ } ) ,
1032+ confirmButtonText : "Donate" ,
1033+ showCancelButton : true ,
1034+ cancelButtonText : t ( { vi : "Để sau" , en : "Later" } ) ,
1035+ showDenyButton : true ,
1036+ denyButtonText : t ( { vi : "Tặng sao" , en : "Star github" } ) ,
1037+ reverseButtons : true ,
1038+ focusConfirm : true ,
1039+ } ) ;
1040+ if ( res . isConfirmed ) {
1041+ Storage . set ( "clickedDonate" , true ) ;
1042+ window . open (
1043+ "https://hoangtran0410.github.io/HoangTran0410/DONATE" ,
1044+ "_blank"
1045+ ) ;
1046+ }
1047+ if ( res . isDenied ) {
1048+ window . open ( "https://github.com/HoangTran0410/useful-script" , "_blank" ) ;
1049+ }
1050+ }
1051+ }
1052+
10161053function saveScroll ( ) {
10171054 const scrollY = window . scrollY ;
10181055 Storage . set ( "popupScrollY" , scrollY ) ;
@@ -1056,4 +1093,5 @@ window.addEventListener("scroll", onScrollEnd);
10561093 } ) ;
10571094
10581095 checkForUpdate ( ) ;
1096+ initShowDonate ( ) ;
10591097} ) ( ) ;
0 commit comments