-
Notifications
You must be signed in to change notification settings - Fork 0
/
mlk.user.v110.js
311 lines (278 loc) · 10.5 KB
/
mlk.user.v110.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
// ==UserScript==
// @name 名录库终结者
// @namespace https://gitee.com/hanj-cn
// @version 1.1
// @description 经济普查是真的累!!!
// @author [email protected]
// @updateURL https://ghproxy.com/?q=https%3A%2F%2Fraw.githubusercontent.com%2Fhanj-cn%2Fmlk%2Fmain%2Fmlk.user.js
// @downloadURL https://ghproxy.com/?q=https%3A%2F%2Fraw.githubusercontent.com%2Fhanj-cn%2Fmlk%2Fmain%2Fmlk.user.js
// @grant unsafeWindow
// @grant GM_setValue
// @grant GM_getValue
// @match http://10.42.31.167/tjmlk/Modules/RecordView/RecordView.aspx?E=%e6%b3%95%e4%ba%ba%e5%8d%95%e4%bd%8d%e8%a1%a8%e7%bb%b4%e6%8a%a4
// @match http://10.42.31.167/tjmlk/Modules/RecordView/RecordView.aspx?E=%u6cd5%u4eba%u5355%u4f4d%u8868%u7ef4%u62a4
// @match http://10.42.31.167/tjmlk/Common/CustomBill.aspx?E=%e4%bf%ae%e6%94%b9%e6%b3%95%e4%ba%ba%e5%8d%95%e4%bd%8d%e8%a1%a8*
// @match http://10.42.31.167/tjmlk/Modules/RecordView/RecordView.aspx?E=%u4ea7%u4e1a%u6d3b%u52a8%u5355%u4f4d%u8868%u7ef4%u62a4
// @match http://10.42.31.167/tjmlk/Modules/RecordView/RecordView.aspx?E=%e4%ba%a7%e4%b8%9a%e6%b4%bb%e5%8a%a8%e5%8d%95%e4%bd%8d%e8%a1%a8%e7%bb%b4%e6%8a%a4
// @match http://10.42.31.167/tjmlk/Common/CustomBill.aspx?E=%e4%bf%ae%e6%94%b9%e4%ba%a7%e4%b8%9a%e6%b4%bb%e5%8a%a8%e5%8d%95%e4%bd%8d%e8%a1%a8*
// @require https://lib.baomitu.com/jquery/latest/jquery.min.js
// ==/UserScript==
//最后更新时间:2023年8月7日09:02:24
(function () {
//新增一个按钮用于操作
function addStartBtn() {
//获取当前网址
var currentUrl = window.location.href;
//判断网址
if (
includeUrl(
currentUrl,
"http://10.42.31.167/tjmlk/Modules/RecordView/RecordView.aspx?E=%u6cd5%u4eba%u5355%u4f4d%u8868%u7ef4%u62a4",
"http://10.42.31.167/tjmlk/Modules/RecordView/RecordView.aspx?E=%e6%b3%95%e4%ba%ba%e5%8d%95%e4%bd%8d%e8%a1%a8%e7%bb%b4%e6%8a%a4",
"http://10.42.31.167/tjmlk/Modules/RecordView/RecordView.aspx?E=%u4ea7%u4e1a%u6d3b%u52a8%u5355%u4f4d%u8868%u7ef4%u62a4",
"http://10.42.31.167/tjmlk/Modules/RecordView/RecordView.aspx?E=%e4%ba%a7%e4%b8%9a%e6%b4%bb%e5%8a%a8%e5%8d%95%e4%bd%8d%e8%a1%a8%e7%bb%b4%e6%8a%a4"
)
) {
//添加操作按钮
$("body").prepend("<button id='startBtn'>操作名录库</button>");
//点击事件
$("#startBtn").click(function () {
if (GM_getValue("data") != null) {
//取出数据
var itemNum = GM_getValue("data").itemNum;
var first = GM_getValue("data").first;
var itemArr = GM_getValue("data").itemArr;
var item;
//构造对象
var data = {
itemArr: itemArr,
first: false,
itemNum: -1,
};
//判断
if (itemNum >= 1) {
if (first) {
item = itemArr[itemArr.length - itemNum];
} else {
item = itemArr[itemArr.length - itemNum + 1];
}
//当不是最后一个数据时
if (itemNum > 1) {
//填充筛选框
fillFilter("社会信用代码", "等于", item.split("*")[0]);
//给#btnSearch添加一个span用于点击
$("#btnSearch").append("<span id='mySpan'></span>");
//点击确定按钮开始搜索
$("#mySpan").click();
}
const jumpBtn = $(
"#dbgData > tbody > tr:nth-child(2) > td:nth-child(2) > a:nth-child(1)"
);
//如果是首次运行的话,需要先搜索一遍,但不点击
if (first) {
data.itemNum = itemNum;
} else {
//不是首次
var resultSize = $("#dbgData > tbody").children().length;
if (resultSize == 3) {
//说明只有一条数据,点击第一条数据
jumpBtn.append("<span id='mySpan1'></span>");
//点击链接跳转
$("#mySpan1").click();
} else {
//异常
console.log(
"搜索结果共" + (resultSize - 2) + "条,程序终止,请自行判断"
);
alert(
"搜索结果共" + (resultSize - 2) + "条,程序终止,请自行判断"
);
}
data.itemNum = itemNum - 1;
}
//记住处理到哪个数据
GM_setValue("data", data);
} else {
GM_setValue("data", null);
console.log("本组数据已处理完毕");
alert("本组数据已处理完毕,辛苦了^_^");
}
} else {
alert("请先初始化");
}
});
}
}
//填充筛选条件
function fillFilter(item, condition, input) {
$("#ddlColumnName").val(item);
$("#cmbOperator").val(condition);
$("#edtFilter").val(input);
}
//添加初始化按钮
function addInitBtn() {
var currentUrl = window.location.href;
if (
includeUrl(
currentUrl,
"http://10.42.31.167/tjmlk/Modules/RecordView/RecordView.aspx?E=%u6cd5%u4eba%u5355%u4f4d%u8868%u7ef4%u62a4",
"http://10.42.31.167/tjmlk/Modules/RecordView/RecordView.aspx?E=%e6%b3%95%e4%ba%ba%e5%8d%95%e4%bd%8d%e8%a1%a8%e7%bb%b4%e6%8a%a4",
"http://10.42.31.167/tjmlk/Modules/RecordView/RecordView.aspx?E=%u4ea7%u4e1a%u6d3b%u52a8%u5355%u4f4d%u8868%u7ef4%u62a4",
"http://10.42.31.167/tjmlk/Modules/RecordView/RecordView.aspx?E=%e4%ba%a7%e4%b8%9a%e6%b4%bb%e5%8a%a8%e5%8d%95%e4%bd%8d%e8%a1%a8%e7%bb%b4%e6%8a%a4"
)
) {
//添加按钮
$("#startBtn").after("<button id='initBtn'>初始化</button>");
//点击事件
$("#initBtn").click(function () {
//输入窗口
var mlkData = prompt("请在下面粘贴数据,至少粘贴三条");
if (mlkData != "") {
//打印日志
console.log("用户输入\n[" + mlkData + "]");
//拆分数据
var mlkDataArr = mlkData.replace(/\r\n/g, "|").split("|");
//数据条数必须不小于3
if (mlkDataArr.length < 3) {
alert("请至少粘贴三条数据");
} else {
//构造对象
var data = {
itemArr: mlkDataArr,
first: true,
itemNum: mlkDataArr.length,
};
//打印日志
console.log(
"初始化完成\n[" + data.itemArr + "]\n共" + data.itemNum + "个数据"
);
//放入油猴存储中
GM_setValue("data", data);
}
} else {
alert("无事发生");
}
});
}
}
//获取css动态前缀
function getCssPrefix() {
var title = document.querySelector("#tdTitle").innerHTML;
var index;
if (
title == "新增法人单位" ||
title == "修改法人单位表" ||
title == "取消剔除法人单位表"
) {
index = 4;
} else if (
title == "新增产业单位" ||
title == "修改产业活动单位表" ||
title == "取消剔除产业活动单位表"
) {
index = 3;
} else {
console.log("无法获取css动态前缀,请勿在此页面提交数据,请关闭本页面!");
}
var prefixId = document.querySelector("tr:nth-child(" + index + ") legend")
.nextElementSibling.id;
var prefix = "#" + prefixId.substring(0, prefixId.indexOf("_") - 2);
console.log("已获取到CSS动态前缀:" + prefix);
return prefix;
}
//判断网址,第一个参数是当前url
function includeUrl(...args) {
//标志
var flag = false;
//循环判断
for (var i = 1; i < args.length; i++) {
if (args[0].includes(args[i])) {
flag = true;
}
}
return flag;
}
//自动填充名录库
function autoFill() {
//判断网址
var currentUrl = window.location.href;
if (
includeUrl(
currentUrl,
"http://10.42.31.167/tjmlk/Common/CustomBill.aspx?E=%e4%bf%ae%e6%94%b9%e6%b3%95%e4%ba%ba%e5%8d%95%e4%bd%8d%e8%a1%a8",
"http://10.42.31.167/tjmlk/Common/CustomBill.aspx?E=%e4%bf%ae%e6%94%b9%e4%ba%a7%e4%b8%9a%e6%b4%bb%e5%8a%a8%e5%8d%95%e4%bd%8d%e8%a1%a8"
)
) {
//提取数据
var itemNum = GM_getValue("data").itemNum;
var itemArr = GM_getValue("data").itemArr;
var areaCode = itemArr[itemArr.length - itemNum - 1].split("*")[1];
//填充数据
if (document.querySelector("#tdTitle").innerHTML == "修改法人单位表") {
setValue(
"03_行政区划代码_旧_edt代码",
areaCode,
"03_行政区划代码_edt代码",
areaCode,
"031_单位注册区划_旧_edt代码",
areaCode
);
//设置颜色
setColor(
"red",
"03_行政区划代码_旧_edt代码",
"03_行政区划代码_edt代码",
"031_单位注册区划_旧_edt代码"
);
} else if (
document.querySelector("#tdTitle").innerHTML == "修改产业活动单位表"
) {
setValue(
"03_行政区划代码_旧_edt代码",
areaCode,
"03_行政区划代码_edt代码",
areaCode
);
//设置颜色
setColor(
"red",
"03_行政区划代码_旧_edt代码",
"03_行政区划代码_edt代码"
);
}
}
}
//填充数据
function setValue(...args) {
for (var i = 0; i < args.length; i++) {
$(getCssPrefix() + args[i]).val(args[i + 1]);
i++;
}
}
//保存数据
function saveValue(...args) {
let arr = [];
for (var i = 0; i < args.length; i++) {
arr.push($(args[i]).val());
}
return arr;
}
//设置字体颜色,第一个参数是颜色
function setColor(...args) {
for (var i = 0; i < args.length; i++) {
$(getCssPrefix() + args[i + 1]).css("color", args[0]);
}
}
//显示变更(a → b)
function showChange(...args) {
var text = "";
for (var i = 0; i < args.length; i++) {
text = text + args[i] + " → " + args[i + 1] + "\n";
i++;
}
return text;
}
addStartBtn();
addInitBtn();
autoFill();
})();