-
-
Notifications
You must be signed in to change notification settings - Fork 124
/
Copy pathEH_SortBook.user.js
49 lines (49 loc) · 1.71 KB
/
EH_SortBook.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
// ==UserScript==
// @name EH_SortBook
// @name:zh-CN 【EH】搜索结果排序
// @author dodying
// @namespace https://github.com/dodying/Dodying-UserJs
// @supportURL https://github.com/dodying/Dodying-UserJs/issues
// @icon http://cdn4.iconfinder.com/data/icons/mood-smiles/80/mood-29-48.png
// @description:zh-CN
// @include http*://exhentai.org/*
// @exclude http*://exhentai.org/g/*
// @version 1
// @grant none
// @run-at document-idle
// ==/UserScript==
const button = document.createElement('button');
button.innerHTML = '排序';
button.className = 'stdbtn';
button.style.zIndex = '999';
button.style.position = 'absolute';
button.style.top = '200px';
button.style.left = `${window.innerWidth - 200}px`;
button.onclick = function () {
const BookDiv = document.querySelectorAll('.it5>a');
const BookTr = document.querySelectorAll('.gtr0,.gtr1');
const BookName = [
];
const BookIndex = {
};
const BookHTML = [
];
console.log(1);
for (var i = 0; i < BookDiv.length; i++) {
BookName.push(BookDiv[i].innerHTML);
BookIndex[BookDiv[i].innerHTML] = i;
}
BookName.sort();
for (var i = 0; i < BookName.length; i++) {
if (BookName[i] in BookIndex) {
BookHTML.push(BookTr[BookIndex[BookName[i]]].outerHTML);
}
}
if (document.querySelector('#EH_CheckForNew')) {
document.querySelector('.itg>tbody').innerHTML = document.querySelector('.itg>tbody>tr').outerHTML + document.querySelector('#EH_CheckForNew').outerHTML + BookHTML.join('');
} else {
document.querySelector('.itg>tbody').innerHTML = document.querySelector('.itg>tbody>tr').outerHTML + BookHTML.join('');
}
this.style.display = 'none';
};
document.body.appendChild(button);