Greasy Fork

Greasy Fork is available in English.

moegirlTable

try to take over the world!

当前为 2019-07-22 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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
// ==/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></table>');

  table.append('<caption>表格的标题</caption><tr><th>表头1</th><th>表头1</th><th>表头1</th><th>表头1</th><th>表头1</th><th>表头1</th><th>表头1</th></tr>');
  listc.forEach(function (t) {

    var tr = '<tr></tr>';
    tr += '<td>' + t.no + '</td>';
    tr += '<td>' + t.name + '</td>';
    tr += '<td>' + t.time + '</td>';
    tr += '<td>' + t.staff + '</td>';
    tr += '<td>' + t.cast + '</td>';
    tr += '<td>' + t.describe + '</td>';
    tr += '<td><img src="' + t.href + '" width="300" height="424"></td>';
    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 = `
  <div id="CWDownContent">
  <div style="width:60px;height:30px;position:fixed;left:5PX;top:5PX;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 () {
    var newwindow = window.open('', "_blank", '');
    var html = '<html><body><table>' + table.html() + '</table></body></html>';
    newwindow.document.write(html);
  };

})();