-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisclaim-element.js
44 lines (40 loc) · 1.13 KB
/
disclaim-element.js
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
37
38
39
40
41
42
43
function getFrameArea(frame) {
if(frame.innerWidth) return frame.innerWidth * frame.innerHeight;
if(frame.document.documentElement && frame.document.documentElement.clientHeight) return frame.document.documentElement.clientWidth * frame.document.documentElement.clientHeight;
if(frame.document.body) return frame.document.body.clientWidth * frame.document.body.clientHeight;
return 0;
}
function isLargestFrame() {
if(top == self) {
return true;
}
if(top.document.body.tagName == "BODY") {
return false;
}
largestArea = 0;
largestFrame = null;
for(i=0;i<top.frames.length;i++) {
frame = top.frames[i];
area = getFrameArea(frame);
if(area > largestArea) {
largestFrame = frame;
largestArea = area;
}
}
return (self == largestFrame);
}
function disclaimElement(element) {
if(isLargestFrame()) {
element.style.display="block";
document.body.insertBefore(element,document.body.firstChild);
}
}
function disclaimToggle(largest, nonLargest) {
if(isLargestFrame()) {
largest.style.display="block";
nonLargest.style.display="none";
} else {
largest.style.display="none";
nonLargest.style.display="block";
}
}