File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -525,14 +525,26 @@ export async function getFbdtsg() {
525525 ( ) => require ( "DTSGInitData" ) . token ,
526526 ( ) => require ( "DTSG" ) . getToken ( ) ,
527527 ( ) => {
528- return document . documentElement . innerHTML . match (
529- / " D T S G I n i t i a l D a t a " , \[ ] , { " t o k e n " : " ( . + ? ) " /
530- ) [ 1 ] ;
528+ return RegExp ( / " D T S G I n i t i a l D a t a " , \[ ] , { " t o k e n " : " ( . + ? ) " / ) . exec (
529+ document . documentElement . innerHTML
530+ ) ?. [ 1 ] ;
531531 } ,
532532 async ( ) => {
533533 let res = await fetch ( "https://mbasic.facebook.com/photos/upload/" ) ;
534534 let text = await res . text ( ) ;
535- return text . match ( / n a m e = " f b _ d t s g " v a l u e = " ( .* ?) " / ) [ 1 ] ;
535+ return RegExp ( / n a m e = " f b _ d t s g " v a l u e = " ( .* ?) " / ) . exec ( text ) ?. [ 1 ] ;
536+ } ,
537+ async ( ) => {
538+ let res = await fetch ( "https://m.facebook.com/home.php" , {
539+ headers : {
540+ Accept : "text/html" ,
541+ } ,
542+ } ) ;
543+ let text = await res . text ( ) ;
544+ return (
545+ RegExp ( / " d t s g " : { " t o k e n " : " ( [ ^ " ] + ) " / ) . exec ( text ) ?. [ 1 ] ||
546+ RegExp ( / " n a m e " : " f b _ d t s g " , " v a l u e " : " ( [ ^ " ] + ) / ) . exec ( text ) ?. [ 1 ]
547+ ) ;
536548 } ,
537549 ( ) => require ( "DTSG_ASYNC" ) . getToken ( ) , // TODO: trace xem tại sao method này trả về cấu trúc khác 2 method trên
538550 ] ;
Original file line number Diff line number Diff line change @@ -48,6 +48,14 @@ export default {
4848 . catch ( ( e ) => sendResponse ( { error : e . message } ) ) ;
4949 return true ;
5050 }
51+
52+ if ( request . action === "fetch" ) {
53+ fetch ( request . url , request . options || { } )
54+ . then ( ( res ) => res . text ( ) )
55+ . then ( sendResponse )
56+ . catch ( ( e ) => sendResponse ( { error : e . message } ) ) ;
57+ return true ;
58+ }
5159 } ,
5260 } ,
5361 } ,
You can’t perform that action at this time.
0 commit comments