-
Notifications
You must be signed in to change notification settings - Fork 1
/
cninfoGraber.user.js
136 lines (123 loc) · 3.46 KB
/
cninfoGraber.user.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
// ==UserScript==
// @name cninfoGraber
// @namespace cninfoGraber
// @description grab cninfo company financial report
// @grant none
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js
// @require http://bainternet-js-cdn.googlecode.com/svn/trunk/js/jQuery%20BlockUI%20Plugin/2.39/jquery.blockUI.js
// @include http://www.cninfo.com.cn/information/*
// @version 1
// ==/UserScript==
function getdata()
{
//var i_nr = document.getElementById("i_nr").contentWindow.document;
var dd = document.getElementsByClassName("clear");
var targetTable,trows,tcells;
var resultArray=new Array()
var resultArrayP = 0;
for(var i=0;i<dd.length;i++)
{
if(dd[i].childElementCount >0)
{
targetTable = dd[i].getElementsByTagName("table");
break;
};
}
if (targetTable!=null)
{
targetTable = targetTable[0];
trows = targetTable.rows;
for(var i=0;i <trows.length;i++)
{
tcells = trows[i].cells;
if (tcells != null)
{
for(var i2=0;i2 <tcells.length;i2++)
{
if (tcells[i2].bgColor == "#daf2ff")
{
resultArray[resultArrayP] = tcells[i2].firstElementChild.innerHTML;
resultArrayP++;
};
}
};
}
}
//resultArray.length = 15;
var resultString = resultArray[0]+" ";
for(var i3=1;i3 <resultArray.length;i3++)
{
i3++;
if (i3 <resultArray.length)
{
if (resultArray[i3]!="")
{
resultString+=resultArray[i3]+" ";
};
};
}
for(var i3=2;i3 <resultArray.length;i3++)
{
i3++;
if (i3 <resultArray.length)
{
if (resultArray[i3]!="")
{
resultString+=resultArray[i3]+" ";
};
};
}
var resultString1=resultString.substr(0, resultString.length-1);
$.blockUI({
theme: false,
showOverlay: false,
draggable: true,
css: {
border: 'none',
top: ($(window).height() - 600) /2 + 'px',
left: ($(window).width() - 800) /2 + 'px',
width: '700px' ,
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .8,
color: '#fff'
},
title: '10秒之内复制',
message: '<textarea rows="1" style="width: 700px;height = 20px" >'+resultString1+'</textarea>',
timeout: 10000
});
$('textarea').click(function(){
if($.browser.msie) this.createTextRange().select();
else {
this.selectionStart = 0;
this.selectionEnd = this.value.length;
}
})
return false;
}
function span1()
{
var res=["SpanGetData"], obj; //需要处理的span id
for(var j=0; j<res.length; j++)
{
obj = document.getElementById(res[j]);
obj.title=obj.id;
obj.j = j;
obj.onclick= function(){getdata();};
}
}
var navbar, newElement;
navbar = document.getElementById('cwzbform');
if (navbar!=null) {
var icon = document.createElement('span');
icon.title = "description";
icon.id = "SpanGetData";
icon.innerHTML = '获取数据';
icon.style.background = "#FFCC00";
icon.style.background = "-moz-linear-gradient(top, #FFCC00, #FF9900)";
icon.style.border = "1px solid #EE8800";
navbar.parentNode.insertBefore(icon, navbar.nextSibling);
span1();
}