74 lines
3.3 KiB
Bash
Executable file
74 lines
3.3 KiB
Bash
Executable file
#! Name: pjscloud.sh
|
|
#! Author: kittykat
|
|
#! Version: 2024.10.14
|
|
#! Desc: Wrapper to use PhantomJSCloud to retrieve url response
|
|
#! Usage: Edit LoadPlugin="" line in mad.sh or mad.config
|
|
#! LoadPlugin="pjscloud.sh"
|
|
#! * Optional: Setup additional / personal PJSCloud accounts
|
|
#!
|
|
#! Notes:
|
|
#! * Returns http query response
|
|
#!
|
|
#! Available Hook Functions:
|
|
#! -------------------------
|
|
#! * OnLoad(): Occurs after load mad.config / load plugins (prior to processing).
|
|
#! * BeginProcessing(): Occurs immediately after beginning processin of urls.txt (loops with Catnaps).
|
|
#! * PreProcessUrl(): occurs immediately after reading in an unprocessed url (^http) line to process.
|
|
#! * PostSuccessfulDownload(): occurs after a download success (is marked #OK# in the urls.txt).
|
|
#! * PostFailedDownload(): occurs after a download fails (is marked #FAIL# in the urls.txt).
|
|
#! * PostFailRetryDownload(): occurs after a download fails with a retry (is marked #RETRY# in the urls.txt).
|
|
#! * DoneProcessingAllUrls(): occurs after all the urls have finished processing (no flocks or other terms downloading).
|
|
#! * PostSuccessfulUpload(): occurs after an upload success (after upload completed ticket is created in ./downloads/).
|
|
#! * PostFailedUpload(): occurs after an upload fails definitively -- #FAIL# in the temp_upload_handler.txt
|
|
#! * PostFailRetryUpload(): occurs after an upload fails with a retry (network drop, unexpected result)
|
|
#! * DoneProcessingAllUploads: occurs after alll the files have finished processing
|
|
#!
|
|
#!
|
|
pjscloud_tor_request() {
|
|
local plugName='pjscloud'
|
|
local plugFunc='pjscloud_tor_request'
|
|
if [ "${DebugPluginsEnabled}" == "true" ]; then
|
|
echo -e "[${PINK}DEBUG${NC}]: Running ${PINK}$plugFunc${NC} in ${BLUE}$plugName${NC} ...${NC}"
|
|
fi
|
|
pjs_targeturl="$1"
|
|
pjs_data="$2"
|
|
if [ -z "$pjs_targeturl" ]; then
|
|
echo "Aborting: No target url specified."
|
|
fi
|
|
GetRandomPjsKey
|
|
if [ ! -z "$pjs_targeturl" ] && [ ! -z "$pjs_data" ] ; then
|
|
pjs_urldata='{"url":"'"$pjs_targeturl"'", urlSettings:{"operation":"POST", "data":"'"$pjs_data"'"}, "renderType":"plainText"}'
|
|
else
|
|
pjs_urldata='{"url":"'"$pjs_targeturl"'", "renderType":"plainText"}'
|
|
fi
|
|
if [ "${UseTorCurlImpersonate}" == "true" ]; then
|
|
response=$("${curl_impersonate[@]}" --proxy "socks5h://${tor_identity}@${TorIp}:${torPort}" \
|
|
--connect-timeout ${ConnectTimeout} \
|
|
--insecure -k -s \
|
|
-H "Content-Type: application/json" \
|
|
-H "Expect:" -X POST \
|
|
-d "$pjs_urldata" \
|
|
"https://PhantomJScloud.com/api/browser/v2/$RandomPjsKey/" & sleep 8s; kill -HUP $! 2>/dev/null)
|
|
else
|
|
response=$(curl --proxy "socks5h://${tor_identity}@${TorIp}:${torPort}" \
|
|
--connect-timeout ${ConnectTimeout} \
|
|
--insecure -k -s \
|
|
-H "Content-Type: application/json" \
|
|
-H "Expect:" -X POST \
|
|
-d "$pjs_urldata" \
|
|
"https://PhantomJScloud.com/api/browser/v2/$RandomPjsKey/" & sleep 8s; kill -HUP $! 2>/dev/null)
|
|
fi
|
|
echo -e "[PJSC_RESPONSE_BEGIN]"
|
|
echo -e "${response}"
|
|
echo -e "[PJSC_RESPONSE_END]"
|
|
}
|
|
#!
|
|
#! --------------- Extra Functions ------------------- #
|
|
#!
|
|
GetRandomPjsKey() {
|
|
arrSize=${#ar_pgsKey[@]}
|
|
index=$(($RANDOM % $arrSize))
|
|
RandomPjsKey=${ar_pgsKey[$index]}
|
|
}
|
|
#! Initialize PJSCloud and get a random key
|
|
GetRandomPjsKey
|