I believe that when a marketplace sells an NFT, it uses the transferFrom or safeTransferFrom function of the contract. Is it possible to change this function to identify whether it was a transfer without or with a sale? And if so, is it possible to get the sale value? Could "msg.value" help with that?
There is no easy way as far as I'm aware but would technically be possible.
The transfer function would be called from the Marketplace's smart contract. You would have keep a record of all the different marketplace's smart contracts addresses and if the sender is one of the marketplace smart contracts like Wyvern Exchange (OpenSea contract) then you would have to look up the transaction data belonging to that sale. However this lookup will differ between marketplace's so I'm not sure its technically viable without incurring a lot of gas costs