Skip to content

Instantly share code, notes, and snippets.

@mjsir911
Last active February 23, 2024 15:04
Show Gist options
  • Save mjsir911/a3bc9bb23775158e240dc56a9717f9f7 to your computer and use it in GitHub Desktop.
Save mjsir911/a3bc9bb23775158e240dc56a9717f9f7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
function firefox2cookiejar() {
# http://fileformats.archiveteam.org/wiki/Netscape_cookies.txt
# https://www.codejam.info/2021/10/bypass-sqlite-exclusive-lock.html
sqlite3 -separator ' ' "file:$1?immutable=1" <<- EOF
.mode tabs
.header off
select host,
case substr(host,1,1)='.' when 0 then 'FALSE' else 'TRUE' end,
path,
case isSecure when 0 then 'FALSE' else 'TRUE' end,
expiry,
name,
value
from moz_cookies;
EOF
}
# firefox2cookiejar ~/.mozilla/firefox/qti9o133.default-esr/cookies.sqlite | grep .amazon.com > cookie-jar.txt
function get_cookie() {
awk -F'\t' -v cookie="$1" '{if ($6==cookie) {print $7}}'
}
# https://stackoverflow.com/questions/42963395/bash-assign-variable-from-pipe
shopt -s lastpipe # weh
curl 'https://horizonte.browserapps.amazon.com/wishlist/tokens' -b cookie-jar.txt \
| jq -r '[.token,.sessionTag] | join(" ")' | read -r "TOKEN" "SESSIONTAG"
curl 'https://horizonte.browserapps.amazon.com/wishlist/dialogbox' -b cookie-jar.txt \
-b cookie-jar.txt \
--data storageKey=AAWishlistProcess12345 \
--data t=$TOKEN \
--data s=$SESSIONTAG \
--data tag=amz-mkt-fox-us-20 \
--data ascsubtag=1ba00-01000-org00-linux-dsk00-nomod-us000-aauwl-feature-home \
--data baseUrl=www.amazon.com \
--data ubpSandboxHandle=1 \
--data cid=$(get_cookie x-main < cookie-jar.txt) \
| xmllint - --html --xpath 'string(//div/@data-param)' 2> /dev/null \
| jq -r '[.addItemSalt,.addItemToken] | join(" ")' | read -r "ADDITEMSALT" "ADDITEMTOKEN"
CID=$(get_cookie x-main < cookie-jar.txt)
DATA=$(jq -n \
--arg CID "$CID" \
--arg ADDITEMSALT "$ADDITEMSALT" \
--arg ADDITEMTOKEN "$ADDITEMTOKEN" \
'{
"cid": $CID,
"comment": "",
"cu": "USD",
"dq": 1,
"iu": "https://cdn.shopify.com/s/files/1/2425/9991/products/1111_f420b51f-2f23-4765-9d7e-a976eb5471bb_1296x.png?v=1667406391",
"lId": "2KBOJ2TGFPGWG",
"lType": "AMAZON_LIST",
"price": "36.50",
"pu": "https://www.dogecore.com/collections/sad-fish-wizard/products/sad-fish-wizard-2",
"s": $ADDITEMSALT,
"t": $ADDITEMTOKEN,
"title": "sad fish wizard – dogecore"
}')
curl 'https://horizonte.browserapps.amazon.com/wishlist/addExternalItem' \
-X POST \
-H 'Content-Type: application/json' \
-H 'Origin: https://horizonte.browserapps.amazon.com' \
--data-raw "$DATA"
@jrgutier
Copy link

does this still work?

@mjsir911
Copy link
Author

not sure! you can always try it out ;-)

@zlatinz
Copy link

zlatinz commented Feb 23, 2024

Currently https://horizonte.browserapps.amazon.com returns a web-page with image saying that it is "temporarily unavailable"
Website temporarily unavailable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment