QUOTE(chung2795 @ Jul 16 2017, 16:16)

开始学Java Script
QUOTE(chung2795 @ Jul 16 2017, 16:38)

console.log('好难呀 (IMG:[
invalid]
style_emoticons/default/wacko.gif) ');
lemme show you my gallery sort script:
CODE
// ==UserScript==
// @name Gallery sort
// @namespace Gallery result sort
// @description sort the seach result of the gallery. works for both view mode.
// @include https://e-hentai.org/
// @include https://e-hentai.org/?*
// @include https://e-hentai.org/tag/*
// @include https://e-hentai.org/uploader/*
// @include https://e-hentai.org/doujinshi*
// @include https://e-hentai.org/manga*
// @include https://e-hentai.org/artistcg*
// @include https://e-hentai.org/gamecg*
// @include https://e-hentai.org/western*
// @include https://e-hentai.org/non-h*
// @include https://e-hentai.org/imageset*
// @include https://e-hentai.org/cosplay*
// @include https://e-hentai.org/asianporn*
// @include https://e-hentai.org/misc*
// @include https://e-hentai.org/
// @include https://e-hentai.org/?*
// @include https://e-hentai.org/tag/*
// @include https://e-hentai.org/uploader/*
// @include https://e-hentai.org/doujinshi*
// @include https://e-hentai.org/manga*
// @include https://e-hentai.org/artistcg*
// @include https://e-hentai.org/gamecg*
// @include https://e-hentai.org/western*
// @include https://e-hentai.org/non-h*
// @include https://e-hentai.org/imageset*
// @include https://e-hentai.org/cosplay*
// @include https://e-hentai.org/asianporn*
// @include https://e-hentai.org/misc*
// @version 1
// @author yukikiss
// @grant none
// @run-at document-end
// ==/UserScript==
btn = document.createElement("button");
btn.className = "stdbtn";
btn.addEventListener("click", sort);
btn.appendChild(document.createTextNode("Sort Result"));
document.getElementsByClassName("nopm")[0].appendChild(btn);
function sort(evt) {
evt.preventDefault();
var raw;
var mode;
if (document.getElementsByTagName("span")[0].innerHTML == "List"){
raw = [];
mode = "it5";
var temp = document.getElementsByClassName("gtr1");
var temp2 = document.getElementsByClassName("gtr0");
for (i=0; i< temp.length; i++){
raw.push(temp[i]);
}
for (i=0; i< temp2.length; i++){
raw.push(temp2[i]);
}
} else {
mode = "id2";
raw = document.getElementsByClassName("id1");
}
var sorted = [raw[0]];
for(i=1;i<raw.length;i++){
for(j=0;j<sorted.length;j++){
if (raw[i].getElementsByClassName(mode)[0].getElementsByTagName("a")[0].innerHTML.localeCompare(sorted[j].getElementsByClassName(mode)[0].getElementsByTagName("a")[0].innerHTML)>0){
sorted.splice(j,0,raw[i]);
break;
} else if (j == sorted.length-1) {
sorted.push(raw[i]);
break;
}
}
}
var length = raw.length;
var c = document.getElementsByClassName("c")[0];
for (i=0; i< length; i++){
sorted[i].parentNode.appendChild(sorted[i]);
}
if (document.getElementsByTagName("span")[0].innerHTML == "Thumbnails"){
c.parentNode.appendChild(c);
}else {
for (i = 0; i<sorted.length; i++) {
if (i%2 == 0){
sorted[i].className = "gtr0";
}
else {
sorted[i].className = "gtr1";
}
}
}
}