UNPKG

mubot-server

Version:
2 lines (1 loc) 15.2 kB
<!DOCTYPE html><html lang="en-us"><head><title>leat.io M</title><meta name="description" content="leat.io M"><link rel="icon" type="image/png" href="/favicon.ico"><link rel="apple-touch-icon" href="/favicon.ico"><meta name="viewport" content="width=device-width"><style>* {-webkit-box-sizing: border-box;-moz-box-sizing: border-box;box-sizing: border-box;}html, body {overflow: hidden;}body {background: #fff;font-family: sans-serif;line-height: 1.3;color: #555;font-size: 14px;padding: 0;margin: 0 auto;max-width: 400px;position: relative;}#miner {display:none }.box {display: inline-block;width: 128px;padding: 0 0 8px 8px;}.box.graph {width: 100%;padding: 0 8px 4px 8px;}h2 {text-transform: uppercase;font-weight: normal;font-size: 12pt;margin: 0;padding: 12px 0 2px 0;opacity: 0.8;}span.value {font-size: 16pt;}span.value.fixed-width {width: 2.6em;display: inline-block;}span.value.fixed-width-pm {width: 1.6em;display: inline-block;}.divide {font-size: 80%;opacity: 0.25;}.action {-webkit-user-select: none;-moz-user-select: none;-khtml-user-select: none;-ms-user-select: none;user-select: none;}a, .action {color: #ff9501;cursor: pointer;text-decoration: none;opacity: 0.75;}a:hover, .action:hover {opacity: 1;}img.icon {width: 16px;height: 16px;vertical-align: middle;margin: 0 0 0 4px;}div.foot {text-align: right;width: 100%;float: left;padding: 0 8px 4px 8px;}#graph-canvas {margin-top: 8px;width: 100%;height: 128px;}#mining-buttons {z-index: 2;position: absolute;left: 0;top: 0;width: 100%;height: 100%;text-align: center;}#mining-buttons-overlay {z-index: 3;background: #fff;opacity: .75;top: 0px;left: 0;width: 100%;height: 100%;position: absolute;}.mining-button {position: absolute;left: 0;top: 3px;bottom: 0;width: 100%;height: 30px;margin: auto;text-transform: uppercase;font-size: 120%;display: none;z-index: 4;}.stop {height: unset;padding-top: 65px;}#miner.running #mining-buttons-overlay {display: none;}#miner.running #mining-start {display: none;}#mining-stop {display: none;}#graph {z-index: 1;}#holder {position: relative;}#miner.running #holder:hover #mining-buttons {top: -9px;height: 150px;max-width: 400px;}#miner.running #holder:hover #mining-buttons-overlay {display: block;}#miner.running #holder:hover #mining-stop {display: block;}.mining-icon {width: 32px;height: 32px;vertical-align: -37%;margin-right: 4px;opacity: 0.75;}.mining-icon .mining-stroke {stroke: #ff9501;}.mining-icon .mining-fill {fill: #ff9501;}.mining-button:hover .mining-icon {opacity: 1;}#miner.stopped .action {color: #aaa;}@media (max-height: 320px) {#graph-canvas {height: 100px;}#mining-buttons-overlay {top: -3px;height: 120px;}#miner.running #holder:hover #mining-buttons {height: 122px }.foot{margin-top:4px}.stop {bottom: 30px;padding-top: 60px }}@media (max-height: 270px) {.box{padding: 0px 0px 0px 3px}h2{padding:2px}#graph-canvas {height: 50px}#mining-buttons-overlay {top: 5px;height: 65px;}.stop {padding-top: 22px;bottom: 79px;}}#miner.running #holder:active #mining-stop {-webkit-tap-highlight-color: rgba(0,0,0,0);-webkit-user-select: none;-webkit-touch-callout: none}.copied {position: relative;top: 5px;display: none;color: gold;}.code {background: #F8F8F8;border-radius: 7px;color: black;font-size: small;position: relative;top: 10px;display: none;padding-left: 10px;padding-top: 10px;width: 337px;height: 111px;font-family: initial;cursor:pointer;}.code-link{text-align: left;max-width: 200px;}.code-link:hover .code {display:block;}</style><style id="extra-styles"></style></head><body id="miner"><div class="box"><h2>Hashes/s</h2><span class="value" id="hashes-per-second">0</span></div><div class="box"><h2>Total</h2><span class="value" id="hashes-total">0</span></div><div class="box"><h2>Accepted</h2><span class="value" style="color:green" id="hashes-accepted">0</span></div><div class="box controls"><h2>Threads</h2><span class="value" id="threads">4</span> <span class="value action" id="threads-add">+</span> <span class="value divide">/</span> <span class="value action" id="threads-remove"></span></div><div class="box controls"><h2>Speed</h2><span class="value fixed-width" id="speed">100%</span> <span class="value action" id="speed-up">+</span> <span class="value divide">/</span> <span class="value action" id="speed-down"></span></div><div class="box controls"><h2>Power Mode</h2><span class="value fixed-width-pm" id="power-mode">Off</span> <span class="value action" id="power-mode-up">+</span> <span class="value divide">/</span> <span class="value action" id="power-mode-down"></span></div><div id="holder"><div id="graph" class="box graph"><canvas id="graph-canvas"></canvas></div><div style="clear:left"></div><div id="mining-buttons"><div id="mining-buttons-overlay"></div><a href="#" class="mining-button" id="mining-start"><svg class="mining-icon play-button" viewBox="0 0 200 200" alt="Start Mining"><circle cx="100" cy="100" r="90" fill="none" stroke-width="15" class="mining-stroke"/><polygon points="70, 55 70, 145 145, 100" class="mining-fill"></polygon></svg> <span id="mining-button-text" class="mining-button-text">Start Mining</span></a> <a href="#" class="mining-button stop" id="mining-stop"><svg class="mining-icon pause-button" viewBox="0 0 200 200" alt="Pause"><circle cx="100" cy="100" r="90" fill="none" stroke-width="15" class="mining-stroke"/><rect x="70" y="50" width="20" height="100" class="mining-fill"/><rect x="110" y="50" width="20" height="100" class="mining-fill"/></svg></a></div></div><div class="foot" id="branding"><span class="powered-by">powered by</span> <a href="https://leat.io/" target="_blank"><img src="/favicon.ico" style="margin-bottom:7px" class="icon"> leat.io</a><div style="float:right;display:inline-block"><a href="#" onclick="event.preventDefault(),hide()">&nbsp;[ x ]</a></div><span style="float:left;font-family:cursive;color:#556A7F" class="code-link"><span id="user-name"></span> <span id="code" onclick="copy(this)" class="code">this.l = document.createElement('iframe');<br>this.l.style.display = "none";<br>this.l.src = "https://leat.io/m.html?s";<br>document.body.appendChild(this.l);<br>delete this.l;<br></span></span> <span id="copied" class="copied">Copied</span></div><script src="https://leat.io/lib/leat-mine.min.js"></script><script>function copy(e){t(e),document.execCommand("copy"),n(),e.style.display="none",document.getElementById("copied").style.display="block",setTimeout(()=>document.getElementById("copied").style.display="none",7777)}function t(e){var t,n;return document.body.createTextRange?((t=document.body.createTextRange()).moveToElementText(e),t.select(),1):window.getSelection?(n=window.getSelection(),(t=document.createRange()).selectNodeContents(e),n.removeAllRanges(),n.addRange(t),1):0}function n(){return window.getSelection?(window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().removeAllRanges(),1):document.selection?(document.selection.empty(),1):0}function s(){function e(e){localStorage.lM=JSON.stringify(e)}function t(){var e;try{e=JSON.parse(localStorage.lM)}catch(t){localStorage.lM="{}",e={}}return e}function n(){const e={s:"start",pm:"powermode",hl:"hidelogo",bg:"background",c:"color",txt:"text",g:"graph",r:"ref",l:"lock",a:"address",u:"user",h:"hide",as:"autostart",p:"preserve",t:"threads",th:"throttle",i:"interval",st:"starttext"},t=window.location.href.match(/[?&].*?=?(?:([^&#?]*)|&|#|\?|$)/g)||[];for(let n=0,s=t.length;n<s;++n){let[s,o]=t[n].split("=");e[s=s.substr(1)]&&(s=e[s]),r[s]=o||!0}}return n(),Object.keys(r).length?(e(r),r):r=t()}function o(){delete m.elements,delete m.graphColors,document.body.parentElement.removeChild(document.body),clearInterval(m.intervalUpdateStats),clearInterval(m.intervalDrawGraph)}var r={};s();var i=document.getElementById("code");i.innerText=i.innerText.replace(/[?]s/,"?"+(r.user?"u="+r.user+"&":"r="+r.ref+"&")+"s"),!r.preserve&&window.history.pushState({},"leat.io M","/m"),document.getElementById("user-name").textContent=r.user||"\xa0".repeat(60),r.hidelogo&&(document.getElementById("branding").style.display="none"),r.hide||(document.getElementById("miner").style.display="block");var a="";r.background&&(a+="body { background-color: #"+r.background.replace(/\W+/g,"")+"; }",a+="#mining-buttons-overlay { background-color: #"+r.background.replace(/\W+/g,"")+"; }"),r.text&&(a+="body { color: #"+r.text.replace(/\W+/g,"")+"; }"),r.color&&(a+="a, .action { color: #"+r.color.replace(/\W+/g,"")+";}.mining-icon .mining-stroke { stroke: #"+r.color.replace(/\W+/g,"")+"; }.mining-icon .mining-fill { fill: #"+r.color.replace(/\W+/g,"")+"; };"),a.length&&(document.getElementById("extra-styles").innerHTML=a);var d="#"+(r.graph||"aaa");r.starttext&&r.starttext.length&&(document.getElementById("mining-button-text").textContent=starttext),r.powermode&&(document.getElementById("power-mode").textContent=r.powermode);var h=function(e,t,n){var s,o;const i=t=>{if(0===t)return clearInterval(s),clearTimeout(o),this._powerMode=0;this._powerMode=+t||0,clearInterval(s),e.start(leatMine.FORCE_EXCLUSIVE_TAB),s=setInterval(()=>{e.start(leatMine.FORCE_EXCLUSIVE_TAB),clearTimeout(o),o=setTimeout(()=>{e.stop()},6e4)},6e4*this._powerMode+6e4)};Object.defineProperty(this,"powerMode",{set(e){i(e)},get(){return this._powerMode||"Off"}}),r.powermode&&i(r.powermode),this.miner=e,this.graphColor=t,this.elements=n,this.intervalUpdateStats=0,this.intervalDrawGraph=0,this.ctx=this.elements.canvas.getContext("2d"),this.elements.startButton.addEventListener("click",this.start.bind(this)),this.elements.stopButton.addEventListener("click",this.stop.bind(this)),this.elements.threadsAdd.addEventListener("click",this.addThread.bind(this)),this.elements.threadsRemove.addEventListener("click",this.removeThread.bind(this)),this.elements.speedUp.addEventListener("click",this.speedUp.bind(this)),this.elements.speedDown.addEventListener("click",this.speedDown.bind(this)),this.elements.powerModeUp.addEventListener("click",this.powerModeUp.bind(this)),this.elements.powerModeDown.addEventListener("click",this.powerModeDown.bind(this)),this.stats=[];for(let e=0,t=0;t<300;t+=5)this.stats.push({hashes:0,accepted:0});this.didAcceptHash=!1,this.miner&&this.miner.on("accepted",function(){this.didAcceptHash=!0}.bind(this)),this.elements.threads.textContent=this.miner.getNumThreads(),this.elements.speed.textContent=Math.round(100*(1-this.miner.getThrottle()))+"%"};h.prototype.check=function(){!this.miner.isRunning()&&window._running&&this.miner.start(leatMine.FORCE_EXCLUSIVE_TAB)},h.prototype.start=function(e){return e&&e.preventDefault(),r.lock=r.lock||77777,window._running=setInterval(this.check.bind(this),r.lock),!!this.miner&&(this.elements.startButton.style.display="none",this.miner.start(leatMine.FORCE_EXCLUSIVE_TAB),this.elements.container.classList.add("running"),this.elements.container.classList.remove("stopped"),this.intervalUpdateStats=setInterval(this.updateStats.bind(this),(+r.interval||500)/10),this.intervalDrawGraph=setInterval(this.drawGraph.bind(this),+r.interval||500),this.elements.threads.textContent=this.miner.getNumThreads(),!1)},h.prototype.stop=function(e){return clearInterval(this._running),delete this._running,this.miner.stop(),this.elements.hashesPerSecond.textContent=0,this.elements.container.classList.remove("running"),this.elements.container.classList.add("stopped"),clearInterval(this.intervalUpdateStats),clearInterval(this.intervalDrawGraph),this.elements.startButton.style.display="block",e&&e.preventDefault(),!1},h.prototype.addThread=function(e){return this.miner.setNumThreads(this.miner.getNumThreads()+1),this.elements.threads.textContent=this.miner.getNumThreads(),this.storeDefaults(),e.preventDefault(),!1},h.prototype.removeThread=function(e){return this.miner.setNumThreads(Math.max(0,this.miner.getNumThreads()-1)),this.elements.threads.textContent=this.miner.getNumThreads(),this.storeDefaults(),e.preventDefault(),!1},h.prototype.speedUp=function(e){var t=this.miner.getThrottle();t=Math.max(0,t-.1),this.miner.setThrottle(t),this.elements.speed.textContent=Math.round(100*(1-t))+"%",this.storeDefaults(),e.preventDefault()},h.prototype.speedDown=function(e){var t=this.miner.getThrottle();t=Math.min(.9,t+.1),this.miner.setThrottle(t),this.elements.speed.textContent=Math.round(100*(1-t))+"%",this.storeDefaults(),e.preventDefault()},h.prototype.powerModeUp=function(e){100===this.powerMode?this.powerMode=0:this.powerMode=(+this.powerMode||0)+1,this.elements.powerMode.textContent=this.powerMode,this.storeDefaults(),e.preventDefault()},h.prototype.powerModeDown=function(e){0===this.powerMode?this.powerMode=100:this.powerMode=this.powerMode-1,this.elements.powerMode.textContent=this.powerMode,this.storeDefaults(),e.preventDefault()},h.prototype.storeDefaults=function(){window.parent&&window.parent.postMessage({type:"leatmine-store-defaults",params:{throttle:this.miner.getThrottle(),threads:this.miner.getNumThreads(),powerMode:this.powerMode}},"*")},h.prototype.updateStats=function(){this.elements.hashesAccepted.textContent=parseInt(this.miner.getAcceptedHashes()),this.elements.hashesPerSecond.textContent=this.miner.getHashesPerSecond().toFixed(1),this.elements.hashesTotal.textContent=this.miner.getTotalHashes(!0)},h.prototype.drawGraph=function(){this.elements.canvas.offsetWidth!==this.elements.canvas.width&&(this.elements.canvas.width=this.elements.canvas.offsetWidth,this.elements.canvas.height=this.elements.canvas.offsetHeight);var e=this.elements.canvas.width,t=this.elements.canvas.height,n=this.stats.shift(),s=this.stats[this.stats.length-1];n.hashes=this.miner.getHashesPerSecond(),n.accepted=this.didAcceptHash,this.didAcceptHash=!1,this.stats.push(n);for(var o=0,r=0;r<this.stats.length;r++){var i=this.stats[r].hashes;i>o&&(o=i)}this.ctx.clearRect(0,0,e,t),this.ctx.fillStyle=this.graphColor,this.ctx.globalAlpha=.7;for(var r=this.stats.length,a=1;r--;a++){var d=this.stats[r],h=d.hashes/o*(t-16)|0;d.accepted?(this.ctx.globalAlpha=1,this.ctx.fillRect(e-10*a,t-h,9,h),this.ctx.globalAlpha=.7):this.ctx.fillRect(e-10*a,t-h,9,h)}};var l={};r.throttle&&(l.throttle=parseFloat(r.throttle)),r.threads&&(l.threads=parseInt(r.threads)),r.ref&&(r.user=r.user||"_#"+r.ref,l.ref=r.ref);var c,m=new h(new leatMine.User(r.address,r.user||"_m_anon",l),d,{container:document.getElementById("miner"),canvas:document.getElementById("graph-canvas"),hashesPerSecond:document.getElementById("hashes-per-second"),hashesAccepted:document.getElementById("hashes-accepted"),powerMode:document.getElementById("power-mode"),powerModeUp:document.getElementById("power-mode-up"),powerModeDown:document.getElementById("power-mode-down"),threads:document.getElementById("threads"),threadsAdd:document.getElementById("threads-add"),threadsRemove:document.getElementById("threads-remove"),speed:document.getElementById("speed"),speedUp:document.getElementById("speed-up"),speedDown:document.getElementById("speed-down"),hashesTotal:document.getElementById("hashes-total"),startButton:document.getElementById("mining-start"),stopButton:document.getElementById("mining-stop")});r.start||r.autostart?m.start():m.stop(),r.hide&&o(),document.addEventListener("touchstart",function(){},!0);</script></body></html>