-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
69 lines (54 loc) · 1.6 KB
/
index.html
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<html>
<head>
<title>专冶各种H5的嵌入垃圾广告</title>
<style type="text/css">
/* 抢先 隐藏 iframe */
body iframe {display: none;}
</style>
</head>
<body>
<div id="xxx_id" style="position: absolute;top:50%;left:50%;width:200px;height:200px;background: #333">
<iframe id="abcd111" src="http://www.itomtan.com/"></iframe>
</div>
<script>
var del_times = 0, deTimer = null;
function adGo() {
var iframe = document.getElementsByTagName('iframe')[0];
console.log('11')
if (iframe) {
console.log(iframe)
//循环 iframe 父类,直到找到body和body的下一级,然后整个嵌入的代码删除。
var bodyNode = { tagName: '' }, iframeParent, targetNode = iframe.parentNode;
while (bodyNode.tagName != 'BODY') {
bodyNode = targetNode;
if (bodyNode.tagName != 'BODY') {
iframeParent = targetNode;
targetNode = targetNode.parentNode;
}
}
if (iframeParent) //如果iframe有父类
bodyNode.removeChild(iframeParent);
else
bodyNode.removeChild(iframe);
}
del_times++;
if (del_times > 8 ) window.clearInterval(deTimer)
};
//抢先 删除 嵌入广告
(function(){adGo();}())
deTimer = self.setInterval(adGo, 500);
//ads demo
setTimeout(() => {
var obj = document.createElement("iframe");
obj.frameborder = 0;
obj.src = "http://www.itomtan.com/";
obj.frameBorder = 0;//FF、IE隐藏边框有效
obj.width = "100px";
obj.height = "100px";
obj.scrolling = "no";
obj.style = "top: 50%;position: fixed;"
document.body.appendChild(obj);
}, 2000);
</script>
</body>
</html>