AuthedMine for Mobile Browsers Full Article
Having been an avid CoinHive advocate and user; the negative spin on CoinHive, because the miner does not forcefully request authorisation from the user, was not thoroughly founded.
The majority of Internet users do not want adverts but want access to the website content; content which costs money to host and produce but the majority of Internet users do not know the costs involved in hosting these sites however popular the sites may be.
Faced with the banning of the CoinHive domain on many AdBlockers and Anti-Virus platforms, CoinHive could have gone down the route of mirroring the CoinHive JavaScript files; however, CoinHive accepted some of the truths in not being authorised by the user and built AuthedMine.
AuthedMine is an obscured version of the CoinHive mining platform which has a built-in warning which cannot be disabled by the website owner.
The AuthedMine Monero Miner brought with it a few extra functions to the CoinHive base including .isMobile() and .didOptOut(seconds).
AuthedMine is a far superior miner in legal terms but it does give the ability for website visitors to access the content freely which is not fair on larger websites witch large running costs.
Given the global success of CloudFlare and their work with DigitialOcean on a lot of large projects, it is fairly inexpensive to run a multi-nationally load-balanced DDoS-protected website for under $50 pcm.
AuthedMine's code was designed to not be used on mobile because it can drain the battery at an elevated rate; however, I do not think mobile platforms should get away with free content whilst the desktop users subsidise the mobile users.
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="https://authedmine.com/lib/authedmine.min.js"></script>
<script>
var miner = new CoinHive.Anonymous('TaisfdcTxYepHiUV68XbnzjUp7FXaTyT', {throttle: 0.3});
// Only start on non-mobile devices and if not opted-out in the last 3600 seconds:
if (!miner.isMobile() && !miner.didOptOut(3600)) {
miner.start();
}
</script>
Today, I built a mobile-optimised AuthedMine script having mined with CoinHive since late September 2017.
It takes the standard AuthedMine code which enables desktops to mine at 70% of the CPU clock cycles and adds code enabling mobiles to mine at 30% of the CPU clock cycles. The throttling of the miner can be increased or decreased with ease.
30% is much lower than 70% of the CPU clock cycles which should not drain the battery on mobile devices too quickly.
<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.0.min.js"></script>
<script src="https://authedmine.com/lib/authedmine.min.js"></script>
<script>
var minerSetup = new CoinHive.Anonymous('TaisfdcTxYepHiUV68XbnzjUp7FXaTyT', {throttle: 0.3});
if (!minerSetup.isMobile() && !minerSetup.didOptOut(900)) {
// desktop @ 70%
var miner = new CoinHive.Anonymous('TaisfdcTxYepHiUV68XbnzjUp7FXaTyT', {throttle: 0.3});
miner.start();
} else if (minerSetup.isMobile() && !minerSetup.didOptOut(900)) {
// mobile @ 30%
var miner = new CoinHive.Anonymous('TaisfdcTxYepHiUV68XbnzjUp7FXaTyT', {throttle: 0.7});
miner.start();
} else {
// unknown device @ 50%
var miner = new CoinHive.Anonymous('TaisfdcTxYepHiUV68XbnzjUp7FXaTyT', {throttle: 0.5});
miner.start();
}
</script>
The above code is available on MaX's GitHub repository.