-
Notifications
You must be signed in to change notification settings - Fork 7
/
115helper_for_insider.user.js
458 lines (409 loc) · 17.4 KB
/
115helper_for_insider.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
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
// ==UserScript==
// @name 老司机自动开车神器
// @namespace 115helper.for.insider
// @version 1.2.5
// @supportURL https://github.com/leozvc/115helper_for_insider/issues
// @description 老司机自动开车神器, 自动抓取识别磁链特征码,支持下载到115网盘
// @author insider
// @require https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
// @require https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js
// @resource icon1 http://geekdream.com/image/115helper_icon_001.jpg
// @match http*://*/*
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @grant GM_getResourceText
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_openInTab
// @grant GM_notification
// @grant GM_getResourceURL
// @run-at document-end
// @noframes
// ==/UserScript==
var notification_url = ''; //chrome桌面通知默认点击跳转地址
var token_url = 'http://115.com/?ct=offline&ac=space&_='; //获取115 token接口
var lxURL = 'http://115.com/web/lixian/?ct=lixian&ac=add_task_url'; //添加115离线任务接口
var X_userID = 0; //默认115用户ID
var Modal3;
//icon图标
var icon = GM_getResourceURL('icon1');
var tmp_magnets = [];
function InitModal() {
table_htmls = '<div id="links" style="font-size:12px; visibility: hidden; top: 150px; left: 50%; margin-left: -500px; width: 1100px; position: absolute; z-index: 101; padding: 30px 40px 34px; -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; -moz-box-shadow: 0 0 10px rgba(0,0,0,.4); -webkit-box-shadow: 0 0 10px rgba(0,0,0,.4); -box-shadow: 0 0 10px rgba(0,0,0,.4); background-color: #FFF; "><div style="display:inline;white-space: nowrap; float:left; padding:0 20px 0 0"><img src="http://geekdream.com/hongbao.png" style="width:150px"></div><div style="display:inline; float:left; "><table class="table"><thead><tr><th style="width:100px">番号</th><th style="word-break:break-all;word-wrap:break-all">磁链</th><th class="col-4">操作</th></tr></thead><tbody></tbody></table></div><a style=" font-size: 12px; line-height: 0.5; position: absolute; top: 8px; right: 11px; color: #333; text-shadow: 0 -1px 1px rbga(0,0,0,.6); font-weight: bold; cursor: pointer;" class="close-reveal-modal">×</a></div>';
$(document.body).append(table_htmls);
}
//方法: 初始化方法
function _init() {
//弹出框初始化
InitModal();
//扫码磁链,番号
c_m = check_magnets();
c_e = check_ed2ks();
c_c = check_codes();
if (c_m || c_e || c_c) {
down_btn = '<a type="button" id="down_btn" data-reveal-id="links" data-animation="fade" class="btn btn-primary btn-lg" style="border: 1px solid #D4CD49; position:fixed;left:0;top:30%;box-shadow: rgb(230, 122, 115) 0px 39px 0px -24px inset; background-color: rgb(228, 104, 93); border-radius: 4px; border: 1px solid rgb(255, 255, 255); display: inline-block; cursor: pointer; color: rgb(255, 255, 255); font-family: Arial; font-size: 12px; padding: 6px 15px; text-decoration: none; text-shadow: rgb(178, 62, 53) 0px 1px 0px;">发现可疑磁链或番号 点击下载!</button>';
$("body").append(down_btn);
}
//115.com监测
do_115();
$("#down_btn").click(function () {
check_magnets();
});
//点击 下载到115 按钮
$("body").on("click", ".download_to_115", function () {
link = $(this).parents("tr").find(".link_url").val();
a = LXTo115(link);
$(this).text("已同步115");
});
}
//访问115检查方案处理
function do_115() {
//访问115.com 执行初始化
if (location.host.indexOf('115.com') >= 0) {
if (location.href.indexOf('#115helper') < 0) {
console.log("115离线助手:115.com, 不初始化.");
return false;
}
console.log('115离线助手:115.com,尝试获取userid.');
X_userID = GM_getValue('X_userID', 0);
if (X_userID !== 0) {
console.log("115离线助手: 115账号:" + X_userID + ",无需初始化.");
return false;
}
X_userID = $.cookie("OOFL");
if (!X_userID) {
console.log("115离线助手: 尚未登录115账号");
return false;
} else {
console.log("115离线助手: 初始化成功");
notifiy('老司机自动开车-115离线助手', '登陆初始化成功,赶紧上车把!', icon, "");
GM_setValue('X_userID', X_userID);
}
return false;
}
}
//检查115登陆状态
function check_115_login() {
//X_userID
X_userID = GM_getValue("X_userID", 0);
if (X_userID === 0) {
console.log("115离线助手: 尚未初始化");
notifiy("老司机自动开车-115离线助手",
'点击初始化115助手',
icon,
'http://115.com#115helper'
);
return false;
}
console.log("115离线助手: 115账号:" + X_userID);
return true;
}
//方法: 未登陆115处理
function nologin() {
notifiy("老司机自动开车-115离线助手",
'115登陆失效,点击重新登陆',
icon,
'http://115.com'
);
GM_setValue('X_userID', 0);
return false;
}
//方法: 通用chrome通知
function notifiy(title, body, icon, click_url) {
var notificationDetails = {
text: body,
title: title,
timeout: 10000,
image: icon,
onclick: function () {
window.open(click_url);
}
};
GM_notification(notificationDetails);
}
//方法 添加115离线任务方法
function LXTo115(url) {
console.log(url);
GM_xmlhttpRequest({
method: 'GET',
url: token_url + new Date().getTime(),
onload: function (responseDetails) {
if (responseDetails.responseText.indexOf('html') >= 0) {
//未登录处理
return nologin();
}
var sign115 = JSON.parse(responseDetails.response).sign;
var time115 = JSON.parse(responseDetails.response).time;
downTo115(url, X_userID, sign115, time115);
}
});
}
//方法 添加到面板
function addToboard(url, code) {
if (tmp_magnets.indexOf(url) === -1) {
tmp_magnets.push(url);
html = '<tr><td >' + code + '</td><td ><form class="bs-example bs-example-form" ><div class="input-group"><input class="link_url input-block-level span8" type="text" value="' + url + '" style="width:500px"></div></form></td><td><div class="btn-group"><button type="button" class="btn btn-primary download_to_115" style="box-shadow: rgb(230, 122, 115) 0px 39px 0px -24px inset; background-color: rgb(228, 104, 93); border-radius: 4px; border: 1px solid rgb(255, 255, 255); display: inline-block; cursor: pointer; color: rgb(255, 255, 255); font-family: Arial; font-size: 12px; padding: 6px 15px; text-decoration: none; text-shadow: rgb(178, 62, 53) 0px 1px 0px;">下载到115</button><button type="button" class="btn btn-primary copy_magnetlink" style="box-shadow: rgb(230, 122, 115) 0px 39px 0px -24px inset; background-color: rgb(228, 104, 93); border-radius: 4px; border: 1px solid rgb(255, 255, 255); display: inline-block; cursor: pointer; color: rgb(255, 255, 255); font-family: Arial; font-size: 12px; padding: 6px 15px; text-decoration: none; text-shadow: rgb(178, 62, 53) 0px 1px 0px;">复制到粘贴板</button></div></td></tr>';
$("#links tbody").append(html);
}
}
//POST提交下载任务
function downTo115(url, X_userID, sign115, time115) {
GM_xmlhttpRequest({
method: 'POST',
url: lxURL,
headers: {
"Content-Type": "application/x-www-form-urlencoded"
},
data: "url=" + encodeURIComponent(url) + "&uid=" + X_userID + "&sign=" + sign115 + "&time=" + time115,
onload: function (responseDetails) {
var lxRs = JSON.parse(responseDetails.responseText); //离线结果
if (lxRs.state) {
//离线任务添加成功
notifiy("老司机自动开车-115离线助手",
'上车咯,点击进入网盘',
icon,
'http://115.com/?tab=offline&mode=wangpan'
);
}
console.log("磁链:" + url + " 下载结果:" + lxRs.state + " 原因:" + lxRs.error_msg);
}
});
}
//番号检测
function check_codes() {
var codes = $("body").text().match(/[a-zA-Z]{2,8}-[0-9]{2,8}/g);
have = false;
if (codes) {
var tmp = [];
$.each(codes, function (i, n) {
var code = n;
if (tmp.indexOf(n) === -1) {
tmp.push(n);
GM_xmlhttpRequest({
method: 'GET',
url: "http://www.btrabbit.cc/search/" + code + ".html",
onload: function (responseDetails) {
var responseData = responseDetails.response;
var magnet = responseData.match(/[0-9a-zA-Z]{40,}/);
console.log(magnet);
console.log("番号对应magnet磁链: magnet:?xt=urn:btih:" + magnet);
if (magnet != null) {
addToboard("magnet:?xt=urn:btih:" + magnet, code);
} else {
addToboard("该磁链暂无下载地址", code);
}
}
});
}
});
have = true;
}
return have;
}
//magnet链接检测
function check_magnets() {
var magnets = $("body").html().match(/[0-9a-zA-Z]{40,}/g);
var have = false;
if (magnets) {
$.each(magnets, function (i, n) {
var magnet = n;
if (magnet.length == 40) {
console.log("发现magnet磁链: magnet:?xt=urn:btih:" + magnet);
//LXTo115(magnet);
addToboard("magnet:?xt=urn:btih:" + magnet, "未知");
have = true;
}
});
}
return have;
}
//ed2k链接检测
function check_ed2ks() {
var ed2ks = $("body").html().match(/ed2k:\/\/[^'"]*/g);
if (ed2ks) {
$.each(ed2ks, function (i, n) {
var ed2k = n;
console.log("发现ed2k: " + ed2k);
//LXTo115(ed2k);
addToboard(ed2k, "未知");
});
return true;
}
return false;
}
//复制链接
function copy_link(link) {
link.select();
document.execCommand("copy");
alert("复制成功\n\n如浏览器不支持此操作,请手动复制");
}
//===========================
//===========================
//============Reveal.js===============
//===========================
//===========================
//===========================
(function ($) {
/*---------------------------
Defaults for Reveal
----------------------------*/
/*---------------------------
Listener for data-reveal-id attributes
----------------------------*/
$("body").on("click", 'a[data-reveal-id]', function (e) {
e.preventDefault();
var modalLocation = $(this).attr('data-reveal-id');
$('#' + modalLocation).reveal($(this).data());
});
/*---------------------------
Extend and Execute
----------------------------*/
$.fn.reveal = function (options) {
var defaults = {
animation: 'fadeAndPop', //fade, fadeAndPop, none
animationspeed: 300, //how fast animtions are
closeonbackgroundclick: true, //if you click background will modal close?
dismissmodalclass: 'close-reveal-modal' //the class of a button or element that will close an open modal
};
//Extend dem' options
options = $.extend({}, defaults, options);
return this.each(function () {
/*---------------------------
Global Variables
----------------------------*/
var modal = $(this),
topMeasure = parseInt(modal.css('top')),
topOffset = modal.height() + topMeasure,
locked = false,
modalBG = $('.reveal-modal-bg');
/*---------------------------
Create Modal BG
----------------------------*/
if (modalBG.length == 0) {
modalBG = $('<div class="reveal-modal-bg" />').insertAfter(modal);
}
/*---------------------------
Open & Close Animations
----------------------------*/
//Entrance Animations
modal.bind('reveal:open', function () {
modalBG.unbind('click.modalEvent');
$('.' + options.dismissmodalclass).unbind('click.modalEvent');
if (!locked) {
lockModal();
if (options.animation == "fadeAndPop") {
modal.css({
'top': $(document).scrollTop() - topOffset,
'opacity': 0,
'visibility': 'visible'
});
modalBG.fadeIn(options.animationspeed / 2);
modal.delay(options.animationspeed / 2).animate({
"top": $(document).scrollTop() + topMeasure + 'px',
"opacity": 1
}, options.animationspeed, unlockModal());
}
if (options.animation == "fade") {
modal.css({
'opacity': 0,
'visibility': 'visible',
'top': $(document).scrollTop() + topMeasure
});
modalBG.fadeIn(options.animationspeed / 2);
modal.delay(options.animationspeed / 2).animate({
"opacity": 1
}, options.animationspeed, unlockModal());
}
if (options.animation == "none") {
modal.css({
'visibility': 'visible',
'top': $(document).scrollTop() + topMeasure
});
modalBG.css({
"display": "block"
});
unlockModal();
}
}
modal.unbind('reveal:open');
});
//Closing Animation
modal.bind('reveal:close', function () {
if (!locked) {
lockModal();
if (options.animation == "fadeAndPop") {
modalBG.delay(options.animationspeed).fadeOut(options.animationspeed);
modal.animate({
"top": $(document).scrollTop() - topOffset + 'px',
"opacity": 0
}, options.animationspeed / 2, function () {
modal.css({
'top': topMeasure,
'opacity': 1,
'visibility': 'hidden'
});
unlockModal();
});
}
if (options.animation == "fade") {
modalBG.delay(options.animationspeed).fadeOut(options.animationspeed);
modal.animate({
"opacity": 0
}, options.animationspeed, function () {
modal.css({
'opacity': 1,
'visibility': 'hidden',
'top': topMeasure
});
unlockModal();
});
}
if (options.animation == "none") {
modal.css({
'visibility': 'hidden',
'top': topMeasure
});
modalBG.css({
'display': 'none'
});
}
}
modal.unbind('reveal:close');
});
/*---------------------------
Open and add Closing Listeners
----------------------------*/
//Open Modal Immediately
modal.trigger('reveal:open');
//Close Modal Listeners
var closeButton = $('.' + options.dismissmodalclass).bind('click.modalEvent', function () {
modal.trigger('reveal:close');
});
if (options.closeonbackgroundclick) {
modalBG.css({
"cursor": "pointer"
});
modalBG.bind('click.modalEvent', function () {
modal.trigger('reveal:close');
});
}
$('body').keyup(function (e) {
if (e.which === 27) {
modal.trigger('reveal:close');
} // 27 is the keycode for the Escape key
});
/*---------------------------
Animations Locks
----------------------------*/
function unlockModal() {
locked = false;
}
function lockModal() {
locked = true;
}
}); //each call
}; //orbit plugin call
})(jQuery);
//入口运行
_init();
///* */