-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
36 lines (26 loc) · 1 KB
/
main.js
File metadata and controls
36 lines (26 loc) · 1 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
javascript:(
function(){
title = document.title;
href = document.location.href;
var output = '['+title+']('+href+')';
execCopy(output);
alert("クリップボードにコピーしました。");
function execCopy(string){
var div = document.createElement('div');
var pre = document.createElement('pre');
pre.style.webkitUserSelect = 'auto';
pre.style.userSelect = 'auto';
div.appendChild(pre).textContent = string;
//divを画面外に持っていく
var s = div.style;
s.position = 'fixed';
s.right = '200%';
document.body.appendChild(div);
document.getSelection().selectAllChildren(div);
var result = document.execCommand('copy');
//divを取り除く
document.body.removeChild(div);
return result;
}
}
)();