Greasy Fork is available in English.
萌娘百科新番列表產生Table
当前为
// ==UserScript==
// @name moegirlTable
// @namespace http://tampermonkey.net/
// @version 1.00
// @description 萌娘百科新番列表產生Table
// @author backrock12
// @match https://zh.moegirl.org/*
// @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js
// @grant none
// ==/UserScript==
(function () {
'use strict';
var table;
function createtable() {
var listc = [];
var num = 1;
var tcaption = $('h1').eq(0).text();
var lista = $('h2');
lista.each(function () {
var t = $(this);
var name = t.text();
if (name != '目录' && name != '导航' && name != '参见' && name != '导航菜单') {
var href = t.nextAll('.thumb').find('img').eq(0).attr('src');
var time = t.nextAll('dl').find('dd').eq(1).text();
var type = t.nextAll('ul').find('li').eq(0);
var describe = t.nextAll('.poem').eq(0);
var staff = t.nextAll('.columns-list').eq(0);
var cast = t.nextAll('.columns-list').eq(1);
var expect = '';
var feedback = '';
describe = describe.length > 0 ? describe.html() : '';
staff = staff.length > 0 ? staff.html() : '';
cast = cast.length > 0 ? cast.html() : '';
time = time.replace('起', '起<br />');
type = type.length > 0 ? type.text() : '';
type = type == '点此进入官方网站' ? '' : type;
var c = { no: num++, name: name, href: href, describe: describe, time: time, staff: staff, cast: cast, type: type, expect: expect, feedback: feedback }
listc.push(c);
}
});
table = $('<table border="1"></table>');
var th = '<caption>' + tcaption + '</caption>';
th += '<tr>';
th += '<th>序号</th>';
th += '<th>名称</th>';
th += '<th>封面</th>';
th += '<th>播出时间</th>';
th += '<th>简介</th>';
th += '<th>STAFF</th>';
th += '<th>CAST</th>';
th += '<th>类型</th>';
th += '<th>期望</th>';
th += '<th>观后感</th>';
th += '</tr>';
table.append(th);
listc.forEach(function (t) {
var tr = '<tr>';
tr += '<td>' + t.no + '</td>';
tr += '<td>' + t.name + '</td>';
tr += '<td><img src="' + t.href + '" width="300" height="424"></td>';
tr += '<td>' + t.time + '</td>';
tr += '<td>' + t.describe + '</td>';
tr += '<td>' + t.staff + '</td>';
tr += '<td>' + t.cast + '</td>';
tr += '<td>' + t.type + '</td>';
tr += '<td>' + t.expect + '</td>';
tr += '<td>' + t.feedback + '</td>';
tr += '</tr>';
table.append(tr);
});
//$('body').append(table);
console.log(listc);
console.log(table);
}
function inits() {
var content = document.createElement("div");
document.body.appendChild(content);
content.outerHTML = `
<div id="CWDownContent">
<div style="width:40px;height:25px;position:fixed;left:3PX;top:3PX;z-index:100000;/*! background-color:#ffffff; *//*! border:1px solid #afb3b6; *//*! opacity:0.95; */filter:alpha(opacity=95);">
<div id="CWDownSave" style="/*! width:43px; *//*! height:26px; */cursor: pointer;background-color:#3169da;/*! margin: 2px 5px 3px 10px; */">
<span style="/*! line-height:25px; */display:block;color:#FFF;text-align:center;font-size: 10px;">产生TABLE</span>
</div>
</div>
</div>
`;
var WCSave = document.querySelector("#CWDownSave");
WCSave.onclick = function () {
createtable();
var newwindow = window.open('', "_blank", '');
var html = '<html><body><table>' + table.html() + '</table></body></html>';
newwindow.document.write(html);
}
}
inits();
})();