forked from ytzong/UserScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hliang.user.js
111 lines (101 loc) · 4.33 KB
/
hliang.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
/// <reference path="jquery-vsdoc.js" />
// ==UserScript==
// @name hliang
// @namespace hliang
// @description hliang
// @include http://bt.hliang.com/*
// ==/UserScript==
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function () {
var script = document.createElement("script");
script.textContent = "(" + callback.toString() + ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
function main() {
/*
var css = "img, input{max-width:100%}.bd{position:relative;}.bd-link{position:absolute;bottom:6px;right:12px;background-color:yellow}#commentarea{display:none;}.intro img{width:900px}.torrent_files{left: 0;position: absolute;top: 31px;background-color:yellow}.torrent_files li{font-weight:bold;font-size:14px}.download{position: absolute; top: 25px; left: 345px;}.bd{position:relative}";
var heads = document.getElementsByTagName("head");
if (heads.length > 0) {
var node = document.createElement("style");
node.appendChild(document.createTextNode(css));
heads[0].appendChild(node);
}
*/
var bdIndex = 0;
var url = document.location.href;
var urls = url.split('/');
var domain = urls[2];
var listSelector = '#listTable';
var bdSelector = '.slayout .c2';
var linkSelector = $(listSelector + ' td:nth-child(3) a:nth-child(1)');
//$(listSelector).hide();
var pageNow = $('.page .current');
var linkCount = linkSelector.length;
$(listSelector).before('<div id="bd-1"></div>');
var nextPage = $('.nextprev:eq(1)').attr('href');
var prevPage = $('.nextprev:eq(0)').attr('href');
function loadBd() {
var link = document.location.href;
var links = link.split('#');
if (links.length > 1) {
var num = parseInt(links[links.length - 1].replace('bd', ''));
bdIndex = num + 1;
$('.bd').hide();
$('#bd' + bdIndex).show();
link = links[0] + '#bd' + bdIndex.toString();
if (bdIndex + 1 > linkCount)
link = nextPage;
for (var i = bdIndex; i < bdIndex + 5; i++) {
if ($('#bd' + i).length < 1) {
$('#bd-1').append('<div id="bd' + i + '" class="bd" style="display:none"><div id="bd-inner' + i + '"></div></div>');
$('#bd' + bdIndex).show();
var bdLink = linkSelector.get(i);
$('#bd-inner' + i).load(bdLink + ' ' + bdSelector);
$('#bd' + i).append('<a class="bd-link" target="_blank" href=' + bdLink +'>' + bdLink +'</a>');
}
}
}
else
link += '#bd-1';
window.location.href = link;
}
loadBd();
//J
$(document).keydown(function (e) {
if(e.keyCode == 74 || e.keyCode == 81) {
loadBd();
}
})
//K
$(document).keydown(function (e) {
if(e.keyCode == 75 || e.keyCode == 87) {
var link = document.location.href;
var links = link.split('#');
if (links.length > 1) {
var num = parseInt(links[links.length - 1].replace('bd', ''));
if (num < 0)
window.location.href = prevPage;
else {
bdIndex = num - 1;
$('.bd').hide();
for (var i = bdIndex; i < bdIndex + 1; i++) {
if ($('#bd' + i).length < 1) {
$('#bd-1').append('<div id="bd' + i + '" class="bd" style="display:none"><div id="bd-inner' + i + '"></div></div>');
var bdLink = linkSelector.get(i);
$('#bd-inner' + i).load(bdLink + ' ' + bdSelector);
$('#bd' + i).append('<a class="bd-link" target="_blank" href=' + bdLink +'>' + bdLink +'</a>');
}
}
link = links[0] + '#bd' + bdIndex.toString();
window.location.href = link;
$('#bd' + bdIndex).show();
}
}
}
})
}
addJQuery(main);