* Follow redirects before Download link dialog. Unwrap Google/DuckDuckGo redirector URLs and HTTP 3xx so long-press Download link opens the dialog with the final file URL, mime, and size. Co-authored-by: Cursor <cursoragent@cursor.com> * Resolve Download link redirects via WebView first. HttpURLConnection often gets Cloudflare 403 HTML for shorteners like rb.gy, which made the dialog offer rg2rd4.html. Prefer a hidden WebView (and ignore HTML error bodies on the HTTP fallback). Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
50 lines
1.9 KiB
Bash
Executable file
50 lines
1.9 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
SRC="${ROOT_DIR}/sources/java/com/mycompany/app/web/DownloadLinkHelper.java"
|
|
OUT_SMALI="${ROOT_DIR}/app/smali_classes4/com/mycompany/app/web"
|
|
TOOLS="${ROOT_DIR}/tools"
|
|
ANDROID_HOME="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-${HOME}/android-sdk}}"
|
|
ANDROID_JAR="$(ls -1 "${ANDROID_HOME}/platforms"/android-*/android.jar 2>/dev/null | sort -V | tail -1)"
|
|
D8="$(find "${ANDROID_HOME}/build-tools" -name d8 -type f 2>/dev/null | sort -V | tail -1)"
|
|
DEX_TOOLS_ZIP="${TOOLS}/dex-tools-v2.4.zip"
|
|
DEX_TOOLS_DIR="${TOOLS}/dex-tools-v2.4"
|
|
|
|
mkdir -p "${TOOLS}" "${OUT_SMALI}"
|
|
|
|
if [[ ! -f "${ANDROID_JAR}" ]]; then
|
|
echo "error: android.jar not found" >&2
|
|
exit 1
|
|
fi
|
|
if [[ -z "${D8}" ]]; then
|
|
echo "error: d8 not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -f "${DEX_TOOLS_DIR}/d2j-dex2jar.sh" ]]; then
|
|
if [[ ! -f "${DEX_TOOLS_ZIP}" ]]; then
|
|
echo "Downloading dex-tools v2.4..."
|
|
curl -fsSL -o "${DEX_TOOLS_ZIP}" \
|
|
"https://github.com/pxb1988/dex2jar/releases/download/v2.4/dex-tools-v2.4.zip"
|
|
fi
|
|
unzip -qo "${DEX_TOOLS_ZIP}" -d "${TOOLS}"
|
|
fi
|
|
chmod +x "${DEX_TOOLS_DIR}/"*.sh "${DEX_TOOLS_DIR}/d2j_invoke.sh" 2>/dev/null || true
|
|
|
|
STAGE="$(mktemp -d)"
|
|
cleanup() { rm -rf "${STAGE}"; }
|
|
trap cleanup EXIT
|
|
|
|
echo "Compiling DownloadLinkHelper..."
|
|
javac --release 11 -classpath "${ANDROID_JAR}" -d "${STAGE}/classes" "${SRC}"
|
|
mkdir -p "${STAGE}/dex"
|
|
mapfile -t CLASS_FILES < <(find "${STAGE}/classes" -name '*.class' -type f)
|
|
"${D8}" --min-api 23 --lib "${ANDROID_JAR}" --output "${STAGE}/dex" "${CLASS_FILES[@]}"
|
|
bash "${DEX_TOOLS_DIR}/d2j-baksmali.sh" -f -o "${STAGE}/out" "${STAGE}/dex/classes.dex"
|
|
find "${STAGE}/out" -name '*.smali' -print0 | xargs -0 sed -i \
|
|
-e 's/\\u002d\$\$Nest\$/\-$$Nest$/g'
|
|
|
|
rm -f "${OUT_SMALI}"/DownloadLinkHelper*.smali
|
|
cp -a "${STAGE}/out/com/mycompany/app/web/DownloadLinkHelper"* "${OUT_SMALI}/"
|
|
echo "Wrote ${OUT_SMALI}/DownloadLinkHelper*.smali"
|