forked from FlominatorTM/WikiTree
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProfile2G2G.js
More file actions
26 lines (26 loc) · 707 Bytes
/
Copy pathProfile2G2G.js
File metadata and controls
26 lines (26 loc) · 707 Bytes
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
javascript:
var title = "" + document.title;
var name = title;
var endName = title.indexOf(" (b.");
if(endName == -1)
{
endName = title.indexOf("|");
}
if(endName > -1)
{
name = title.substr(0, endName);
}
var node = document.createElement("div");
node.innerHTML = '<a href="' + window.location + '">' + name + '</a>';
copyToClip(node.innerHTML);
alert("copied to clipboard:" + node.innerHTML);
function copyToClip(str) {
function listener(e) {
e.clipboardData.setData("text/html", str);
e.clipboardData.setData("text/plain", str);
e.preventDefault();
}
document.addEventListener("copy", listener);
document.execCommand("copy");
document.removeEventListener("copy", listener);
};a