Hard time distinguishing change and withdraw amount for P2SH address I am trying to extract the exact amount of BTC deposited and withdrawn from BTC address (from hardware wallets like Trezor, ledger nano, ...). So if the address is pay-to-pubkey-hash then I can easily track amount through its transaction id hash -> outputs   BUT when the address is pay-to-script-hash then I am having a hard time recognizing which one is Change and which one is withdrawing amount from Txn Hash detail. Is there any way to distinguish change and withdraw amount for P2SH address.
eg:
P2SH: https://api.blockcypher.com/v1/btc/main/txs/87d5fa33ae3f1754bb1618c8559b8451f64de1e396627fad65a19b74b2c72b86 ( difficulty finding)

https://api.blockcypher.com/v1/btc/main/txs/d7cdb1f910ac15d99ee98a28c276ccfccd5fd6592cf01528eb57a871e789b709 ( This is easier as output is withdraw amount)
It is not possible to discern with absolute certainty which output is a 'payment' and which is the change address (I put payment in quotations because a transaction does not always represent a transfer of coins between two parties, sometimes it might just be someone moving coins to a new wallet they also control, for example).

Sometimes it may be possible to make an educated guess based on input/output values, but this is not always the case. In fact, some wallets may be designed to intentionally obfuscate this data, in an effort to maintain user privacy.

Unless I am misunderstanding your question, there is no difference between P2PKH and P2SH in this regard. The bitcoin address and payment amount is clearly listed for each output in the examples you provided.