-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRandomGuid.js
More file actions
23 lines (22 loc) · 801 Bytes
/
Copy pathRandomGuid.js
File metadata and controls
23 lines (22 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
javascript: (function () {
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
}
function copy(text) {
var input = document.createElement('input');
input.style.position = 'fixed';
input.style.opacity = 0;
input.value = text;
document.body.appendChild(input);
input.select();
var successful = document.execCommand('copy');
document.body.removeChild(input);
return successful;
}
var uuid = guid();
var successful = copy(uuid);
window.alert(successful ? "Copied to clipboard UUID = " + uuid : "Failed to copy UUID");
})()