1+ import  {  writeFileSync ,  readFileSync  }  from  "fs" 
2+ 
3+ function  getChinaDate ( )  { 
4+   const  chinaDate  =  new  Intl . DateTimeFormat ( 'zh-CN' ,  { 
5+     timeZone : 'Asia/Shanghai' , 
6+     year : 'numeric' , 
7+     month : '2-digit' , 
8+     day : '2-digit' 
9+   } ) . format ( new  Date ( ) ) ; 
10+   return  chinaDate . replace ( / ^ ( \d { 2 } ) / ,  "" ) . replace ( / \/ / g,  '/' ) 
11+ } 
12+ 
13+ const  kPageUrl  =  `https://gist.githubusercontent.com/d1y/4d0551fc8105c9d57f85da8cbbdc8b2e/raw/fabu.html` 
14+ 
15+ const  config  =  { 
16+   sponsorship : "https://s2.loli.net/2025/09/24/ByRvOsQhWzKLXNo.jpg" , 
17+   sourceTotal : 0 , 
18+   update : getChinaDate ( ) , 
19+   baseUrl : "https://d1y.github.io/kitty" , 
20+ } 
21+ 
22+ function  getSourceTotal ( )  { 
23+   let  total  =  0 
24+   const  files  =  [ "vod.json" ,  "xvod.json" ,  "x.json" ,  "t4.json" ] 
25+   for  ( const  file  of  files )  { 
26+     try  { 
27+       const  list : any [ ]  =  JSON . parse ( readFileSync ( file ,  "utf8" ) ) 
28+       total  +=  list . length 
29+     }  catch  ( error )  { 
30+       console . error ( error ) 
31+     } 
32+   } 
33+   return  total 
34+ } 
35+ 
36+ ; ( async  ( ) =>  { 
37+   const  total  =  getSourceTotal ( ) 
38+   let  text  =  await  ( await  fetch ( kPageUrl ) ) . text ( ) 
39+   for  ( const  [ key ,  value ]  of  Object . entries ( config ) )  { 
40+     let  realValue  =  '' + value 
41+     if  ( key  ==  "sourceTotal" )  { 
42+       realValue  =  `${ total }  
43+     } 
44+     text  =  text . replaceAll ( `$$${ key }  ,  realValue ) 
45+   } 
46+   const  file  =  process . argv [ 2 ] 
47+   writeFileSync ( file ,  text ) 
48+ } ) ( ) 
0 commit comments