2022-10-03 12:39:49 +00:00
const tabIDs = { } ;
const textDecoder = new TextDecoder ( ) ;
function requestToClipboard ( tabId ) {
chrome . tabs . get ( tabId , ( details ) => {
const req _headers = tabIDs [ details . id ] . playback _request [ 0 ] ? . playback _headers ;
const req _url = tabIDs [ details . id ] . playback _url ;
const req _data _json = tabIDs [ details . id ] . playback _data ;
if ( ! req _headers )
return ;
// Fetching the user's ip for setting the header x-forwarded-for.
// This might help to bypass regional restrictions when performing the playback request in some cases.
const ip _retrieve _link = "https://ipinfo.io/ip" ;
var get _ip = new XMLHttpRequest ( ) ;
get _ip . open ( 'GET' , ip _retrieve _link , true ) ;
get _ip . onload = function ( ) {
var ip _resposnse = this . responseText ;
console . log ( ip _resposnse ) ;
var i = 0 ;
let curl _playback _data = "curl " ;
curl _playback _data += ` ' ${ req _url } ' \\ ` ;
for ( ; i < req _headers . length ; ++ i )
curl _playback _data += ` \n -H ' ${ req _headers [ i ] . name . toLowerCase ( ) } : ${ req _headers [ i ] . value } ' \\ ` ;
curl _playback _data += ` \n -H 'x-forwarded-for: ${ ip _resposnse } ' \\ ` ;
curl _playback _data += "\n --data-raw " ;
curl _playback _data += ` ' ${ req _data _json } ' \\ ` ;
curl _playback _data += "\n --compressed" ;
// Generating the curl license text link for https://t.me/drm_downloader_robot
const zee5 _gen _link = "https://drm-bot.herokuapp.com/zee5.php" ;
var data = new FormData ( ) ;
data . append ( 'playlist' , curl _playback _data ) ;
data . append ( 'api' , 'api' ) ;
var gen _link = new XMLHttpRequest ( ) ;
gen _link . open ( 'POST' , zee5 _gen _link , true ) ;
gen _link . onload = function ( ) {
var gen _link _resposnse = this . responseText ;
let json _resp = JSON . parse ( gen _link _resposnse ) ;
console . log ( json _resp ) ;
let generated _playback _link = json _resp . data ;
const final = ` ${ generated _playback _link } ` ;
console . log ( final ) ;
const copyText = document . createElement ( "textarea" ) ;
copyText . style . position = "absolute" ;
copyText . style . left = "-5454px" ;
copyText . style . top = "-5454px" ;
copyText . style . opacity = 0 ;
document . body . appendChild ( copyText ) ;
copyText . value = final ;
copyText . select ( ) ;
document . execCommand ( "copy" ) ;
document . body . removeChild ( copyText ) ;
chrome . browserAction . setBadgeBackgroundColor ( { color : "#FF0000" , tabId : details . id } ) ;
chrome . browserAction . setBadgeText ( { text : "📋" , tabId : details . id } ) ;
2022-10-03 12:48:04 +00:00
console . log ( "The required zee5 link's data has been copied to your clipboard successfully!\n\nNow go to https://t.me/drm_downloader_robot and paste it and send it to the bot." ) ;
2022-10-03 12:39:49 +00:00
}
gen _link . send ( data ) ;
}
get _ip . send ( ) ;
} ) ;
}
function getPlaybackRequestData ( details ) {
tabIDs [ details . tabId ] = tabIDs [ details . tabId ] || { } ;
if ( details . requestBody && details . requestBody . raw && details . method == "POST" ) {
for ( var j = 0 ; j < details . requestBody . raw . length ; ++ j ) {
try {
const decodedString = textDecoder . decode ( details . requestBody . raw [ j ] . bytes ) ;
tabIDs [ details . tabId ] = { playback _data : decodedString , playback _request : [ ] , playback _url : details . url , req _id : details . requestId } ;
} catch ( e ) {
console . error ( e ) ;
}
}
}
}
chrome . webRequest . onBeforeRequest . addListener (
getPlaybackRequestData ,
{ urls : [ "https://spapi.zee5.com/singlePlayback/getDetails/*" ] , types : [ "xmlhttprequest" ] } ,
[ "requestBody" ]
) ;
function getPlaybackRequestHeaders ( details ) {
if ( details . method == "POST" && tabIDs [ details . tabId ] && tabIDs [ details . tabId ] . playback _url === details . url && tabIDs [ details . tabId ] . req _id === details . requestId ) {
console . log ( details . url ) ;
tabIDs [ details . tabId ] . playback _request . push ( { playback _headers : details . requestHeaders } ) ;
requestToClipboard ( details . tabId ) ;
}
}
chrome . webRequest . onSendHeaders . addListener (
getPlaybackRequestHeaders ,
{ urls : [ "https://spapi.zee5.com/singlePlayback/getDetails/*" ] , types : [ "xmlhttprequest" ] } ,
[ "requestHeaders" ]
) ;