First. This would never work with Bitcoin. You would need a ASIC resistant algo such as Monero. And this is exactly what coinhive does.
However coinhive is now blocked as malware (as it should be).
I played with it for a bit and unless you are Reddit it would take forever to get a single payout. Mining in the browser is so very inefficient. And if you are on a phone or laptop it fucks your battery.
When I played with coinhive I spent a few days making sure some conditions were met if I would run it. If mobile… DO NOT RUN.. Batteries get killed running it. I also didn’t turn it on unless your were on the site for four consecutive hours. And I made you opt into it.
People did and the earnings were shit. Like totally not worth it. It would have taken a year to get ten bucks. Easier to just use buymeacoffee.. https://imgur.com/a/f6fqnbU