// ==UserScript== // @name moegirlTable // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://zh.moegirl.org/* // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; var listc = []; var num = 0; 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 describe = t.nextAll('.poem').eq(0); var staff = t.nextAll('.columns-list').eq(0); var cast = t.nextAll('.columns-list').eq(1); describe = describe.length > 0 ? describe.html() : ''; staff = staff.length > 0 ? staff.html() : ''; cast = cast.length > 0 ? cast.html() : ''; var c = { no: num++, name: name, href: href, describe: describe, time: time, staff: staff, cast: cast } listc.push(c); } }); var table = $('
'); table.append('表格的标题表头1表头1表头1表头1表头1表头1表头1'); listc.forEach(function (t) { var tr = ''; tr += '' + t.no + ''; tr += '' + t.name + ''; tr += '' + t.time + ''; tr += '' + t.staff + ''; tr += '' + t.cast + ''; tr += '' + t.describe + ''; tr += ''; tr += ''; table.append(tr); }); $('body').append(table); console.log(listc); console.log(table); var content = document.createElement("div"); document.body.appendChild(content); content.outerHTML = `
产生TABLE
`; var WCSave = document.querySelector("#CWDownSave"); WCSave.onclick = function () { var newwindow = window.open('', "_blank", ''); var html = '' + table.html() + '
'; newwindow.document.write(html); }; })();