// ==UserScript==
// @name 悬浮计算器
// @version 0.1
// @description 一个html实现的悬浮在页面的简单计算器,下滑显示,上滑隐藏
// @author byzapp
// @run-at document-end
// @match https://*/*
// @grant none
// ==/UserScript==
!function(){if(!document.getElementById("bzyapp")){var t=document.createElement("div");t.id="bzyapp",t.innerHTML="<html> <head> \t<title>计算器</title> \t<meta charset='utf-8'> <meta name='viewport' content='width=device-width, initial-scale=1.0, user-scalable=no'> \t<style type='text/css'> \t#is{height: 166px;} \t\t.butt{ \t\t\theight:52px; \t\t\twidth: 60px; \t\t\tbackground: #484949; \t\t\tborder-width: 0; \t\t\tcursor: pointer; \t\t\tcolor: white; \t\t\tfont-size: 30px; \t\t\tborder-color: blue;} \t\t\t \t\t#end{ \t\t\tfont-size: 34px; \t\t\tmax-width: 316px; \t\t\toverflow: hidden; \t\t\ttext-overflow: ellipsis; \t\t\twhite-space: nowrap;} \t</style> </head> <body> \t<table border='5px' align='center'> \t\t<tr height='80px'><td width='312px'><div id='end'></div></td></tr> \t</table> \t \t<table border='5px' cellspacing='0' align='center' onclick='show()'>\t \t\t<tr height='54px'> \t\t\t<td><button class='butt'>7</button></td> \t\t\t<td><button class='butt'>8</button></td> \t\t\t<td><button class='butt'>9</button></td> \t\t\t<td><button class='butt'>+</button></td> \t \t\t\t<td><button class='butt' onclick='clearly()'>C</button></td> \t\t</tr> \t\t<tr height='54px'> \t\t\t<td><button class='butt'>4</button></td> \t\t\t<td><button class='butt'>5</button></td> \t\t\t<td><button class='butt'>6</button></td> \t\t\t<td><button class='butt'>-</button></td> \t \t\t\t<td rowspan='3'> \t\t\t\t<button class='butt' id='is' onclick='Calculate()'>=</button> \t\t\t</td> \t\t</tr> \t\t<tr height='54px'> \t\t\t<td><button class='butt'>1</button></td> \t\t\t<td><button class='butt'>2</button></td> \t\t\t<td><button class='butt'>3</button></td> \t\t\t<td><button class='butt'>*</button></td> \t\t</tr> \t\t<tr height='54px'> \t\t\t<td><button class='butt'>0</button></td> \t\t\t<td><button class='butt'>.</button></td> \t\t\t<td><button class='butt'>00</button></td> \t\t\t<td><button class='butt'>/</button></td> \t\t</tr> \t</table> </body> </html>",t.style.cssText="display:none;!important;text-align:center;float:right;position:fixed;right:0px;top:0px;color:#000;background:#fff;cursor:pointer;position:fixed !important;z-index:9999999999 !important;box-shadow:0px 0px 10px #888;!important;-webkit-tap-highlight-color:transparent;!important;user-select:none",document.body.appendChild(t)}var e,n;document.addEventListener("touchstart",function(t){e=t.changedTouches[0].clientY}),document.addEventListener("touchmove",function(t){n=t.changedTouches[0].clientY,document.getElementById("bzyapp").style.display=n-e>0?"block":"none"})}();var a="",bool=!1;function show(){element=event.srcElement.innerText,"="!=element&&"C"!=element&&(bool&&"+"!=element&&"/"!=element&&"*"!=element&&"-"!=element&&(a=""),bool=!1,a+=element,document.getElementById("end").innerText=a)}function Calculate(){bool=!0,document.getElementById("end").innerText=eval(a),a=eval(a),a>=999999&&(a="Err")}function clearly(){a="",document.getElementById("end").innerText="0"}
Back to home |
File page
Subscribe |
Register |
Login
| N