-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetchu.user.js
87 lines (73 loc) · 2.15 KB
/
getchu.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
// ==UserScript==
// @name Getchu
// @namespace [email protected]
// @description copy name and URL easily
// @include http://www.getchu.com/*
// @grant none
// ==/UserScript==
function createTextArea(name, url) {
var text = document.createElement("textarea");
text.value = name + "\n" + url;
text.rows = 2;
text.cols = 50;
text.readOnly = true;
return text;
}
function searchForm() {
function selVal(sel, val) {
var opts = sel.options;
for(var i = 0; i < opts.length; ++i) {
if(opts[i].value == val) {
opts[i].selected = true;
break;
}
}
}
selVal(document.getElementsByName('genre')[2], 'pc_soft');
selVal(document.getElementsByName('age')[0], '18:lady');
selVal(document.getElementsByName('sort2')[0], 'up');
const unit = 86400000;
var now = new Date();
var start = new Date(now.getTime() - now.getDay() * unit);
var end = new Date(start.getTime() + 7 * unit);
var fmt = '%Y/%m/%d'
document.getElementsByName('start_date')[0].value = start.toLocaleFormat(fmt);
document.getElementsByName('end_date')[0].value = end.toLocaleFormat(fmt);
}
function searchPage() {
var links = document.links;
for(var i = 0; i < links.length; ++i) {
if(links[i].className != 'greenb' && links[i].className != 'blueb')
continue;
var paren = links[i].parentNode
paren.appendChild(document.createElement('br'));
paren.appendChild(
createTextArea(
links[i].textContent,
links[i].href
)
);
}
}
function infoPage() {
var title = document.getElementById('soft-title');
title.appendChild(document.createElement('br'));
title.appendChild(
createTextArea(
title.firstChild.textContent.replace(/^\s+|\s+$/g, ''),
document.URL
)
);
}
switch(location.pathname) {
case '/php/search_top.phtml':
case '/php/nsearch_top.phtml':
searchForm();
break;
case '/php/search.phtml':
searchPage();
break;
case '/soft.phtml':
infoPage();
break;
}