-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
158 lines (125 loc) · 3.84 KB
/
script.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
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
window.onload=function(){
var body = document.body;//document.getElementsByName("body");
// var body = document.getElementById("top");
var main = document.getElementsByClassName("l-side-margins")[0];
// var footer = ;
main.removeChild(main.getElementsByClassName("content-footer")[0]);
var del = document.getElementsByClassName("element-rich-link")[0];
del.parentNode.removeChild(del);
setTimeout(function(){
del = document.getElementsByClassName("js-ad-slot");
for (var i = 0; i < del.length; i ++) {
while (del[i]) {
del[i].parentNode.removeChild(del[i]);
}
}
del = document.getElementsByClassName("element")[0];
if(del)
del.parentNode.removeChild(del);
}, 2000)
for (var i = 0; i < body.childNodes.length; i ++) {
// body.childNodes[i]
while (body.childNodes[i] && body.childNodes[i] != main) {
// statement
body.removeChild(body.childNodes[i]);
}
}
var content = document.getElementsByClassName("content__main-column")[0];
var page = parseInt(body.scrollHeight/window.screen.availHeight);
for (var i = 0; i < page; i++) {
(function(i) {
var div = document.createElement("div");
var button = document.createElement("button");
var t=document.createTextNode(i);
button.appendChild(t);
div.appendChild(button);
button.style.position = 'fixed';
button.style.opacity = '0.6';
// button.style.float = 'right';
button.style.right = '0'
button.style.bottom = 50 * (page - i) + 'px';
button.style.zIndex = "1000";
button.onclick = function() {
// scroll(0,body.scrollHeight)
scroll(0,i * window.screen.availHeight);
}
body.appendChild(button);
})(i);
}
var _div;
body.onmousedown = function(e){
if(_div){
body.removeChild(_div);
_div = undefined;
}
}
body.onmouseup = function(e){
txt = window.getSelection();
var xmlhttp;
if (window.XMLHttpRequest)
{
// IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
xmlhttp=new XMLHttpRequest();
}
else
{
// IE6, IE5 浏览器执行代码
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
// document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
var res = JSON.parse(xmlhttp.responseText);
if(!res.status_code){
_div = document.createElement("div");
_div.innerHTML = res.data.cn_definition.defn;
_div.style.position = 'absolute';
_div.style.top = e.pageY + 'px';
_div.style.left = e.pageX + 'px';
_div.style.backgroundColor = 'pink';
_div.style.opacity = '0.8';
_div.style.border = '2px';
_div.style.borderRadius = '1px';
_div.style.zIndex = "1000";
_div.onmousedown = function(e){
if(e && e.stopPropagation){
//W3C取消冒泡事件
e.stopPropagation();
}else{
//IE取消冒泡事件
window.event.cancelBubble = true;
}
}
_div.onmouseup = function(e){
if(e && e.stopPropagation){
//W3C取消冒泡事件
e.stopPropagation();
}else{
//IE取消冒泡事件
window.event.cancelBubble = true;
}
}
var laba = document.createElement("button");
var img = document.createElement("img");
img.src = "https://cdn-img.easyicon.net/png/12013/1201363.gif";
img.style.width = img.style.height = "20px";
laba.style.padding = '0';
laba.style.width = laba.style.height = "24px";
laba.appendChild(img);
_div.appendChild(laba);
laba.onclick = function(){
var au = document.createElement("audio");
au.preload="auto";
au.src = "https" + res.data.audio.substring(4)
au.play();
}
body.appendChild(_div);
}
}
}
xmlhttp.open("GET","https://api.shanbay.com/bdc/search/?word=" + txt, true);
xmlhttp.send();
}
}