-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathparse_eth.js
More file actions
36 lines (29 loc) · 1.21 KB
/
parse_eth.js
File metadata and controls
36 lines (29 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
if (typeof parseEth === 'undefined') {
const parseEth = function () {
window.addEventListener("dblclick", function (e) {
const number = window.getSelection().toString();
const result = parseInt(number) / 10e17
if (number.startsWith('0x') || isNaN(result) || result == 0 || result < 0.0009) {
return
}
const node = document.createElement("div");
node.style.left = e.pageX + 'px'
node.style.top = e.pageY + 'px'
node.style.zIndex = 1337;
node.style.position = 'absolute'
node.style.backgroundColor = 'red';
node.style.color = 'black'
node.style.borderRadius = '5px';
node.style.fontSize = '1.2em';
node.style.padding = '0 5px 0 5px';
node.style.backgroundColor = 'black';
node.style.color = 'white'
node.style.borderRadius = '8px';
node.style.marginTop = '8px';
node.appendChild(document.createTextNode(`${result} ETH`));
document.body.appendChild(node);
setTimeout(function() { node.remove(); }, 2000);
});
}
parseEth()
}