It seems ironic for the maker of the Coinhive JavaScript code, widely used for cryptojacking, to claim that Coinhive is an alternative to classic ad banners. But the idea behind a code like Coinhive is not illegal. Provided it is not abused. In principle, a code integrated into websites, via which visitors consciously agree to mining, can be a safe alternative to advertisements that lead to malicious scam or phishing sites or stealing of sensitive user data.
The prerequisite for this is that page visitors agree to offer a portion of their computing power for the website visit, as is the case with cookie queries. In this way, website operators finance themselves even without a high density of uncontrolled advertising. However, this could only be implemented through independent standards and transparency of cryptomining codes in web projects. A successful example for the legal use of Coinhive was a donation initiative of UNICEF Australia, where donations were generated through website visits.