Greasy Fork

yugioh wiki card info

try to take over the world!

目前为 2016-08-29 提交的版本。查看 最新版本

// ==UserScript==
// @name         yugioh wiki card info
// @namespace    http://tampermonkey.net/
// @version      0.6
// @description  try to take over the world!
// @author       You
// @match        http://yugioh.wikia.com/wiki/*
// @grant        none
//@require       https://code.jquery.com/jquery-3.1.0.min.js
// ==/UserScript==

$(document).ready(function () {
    var card = {
        "id": 1,
        "type": "monster",
        "name": (($('.cardtablerowdata').eq(0)).text()).replace('\n', ''),
        "text": $('.collapsible.expanded.navbox-inner .navbox-list i').text(),
        "score": parseFloat((Math.random() * (10 - 1) + 1).toFixed(1)),
        "atk": parseInt(($('.cardtablerowdata').eq(10).find('a:first-child')).text()),
        "def": parseInt(($('.cardtablerowdata').eq(10).find('a:last-child')).text()),
        "level": parseInt(($('.cardtablerowdata').eq(9).find('a:first-child')).text())
    };
    
    //alert(JSON.stringify(card, null, 4));
    //console.log('ASDASDASDASD', $('.cardtablerowdata'));
    
    var container = $('<div><pre>' + JSON.stringify(card, null, 4) + ',' + '</pre></div>');
    container.css({
        position: 'absolute',
        top: '100px',
        left: '10px',
        background: 'white',
        padding: '20px',
        'z-index': 5000,
        'border-radius': '5px',
        border: '1px solid black',
        'box-shadow': '0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)'
    });
    
    $('body').append(container);
});