-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathView Partial Source.js
More file actions
33 lines (30 loc) · 1000 Bytes
/
View Partial Source.js
File metadata and controls
33 lines (30 loc) · 1000 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
27
28
29
30
31
32
33
javascript: function getSelSource() {
x = document.createElement("div");
x.appendChild(window.getSelection().getRangeAt(0).cloneContents());
return x.innerHTML;
}
function makeHR() {
return nd.createElement("hr");
}
function makeParagraph(text) {
p = nd.createElement("p");
p.appendChild(nd.createTextNode(text));
return p;
}
function makePre(text) {
p = nd.createElement("pre");
p.appendChild(nd.createTextNode(text));
return p;
}
nd = window.open().document;
ndb = nd.body;
if (!window.getSelection || !window.getSelection().rangeCount || window.getSelection().getRangeAt(0).collapsed) {
nd.title = "Generated Source of: " + location.href;
ndb.appendChild(makeParagraph("No selection, showing generated source of entire document."));
ndb.appendChild(makeHR());
ndb.appendChild(makePre("<html>\n" + document.documentElement.innerHTML + "\n</html>"));
} else {
nd.title = "Partial Source of: " + location.href;
ndb.appendChild(makePre(getSelSource()));
};
void 0