Decklog WS Deck Output

try to take over the world!

目前為 2021-03-12 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Decklog WS Deck Output
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  try to take over the world!
// @author       You
// @match        https://decklog.bushiroad.com/view/*
// @grant        none
// ==/UserScript==


function ButtonClickAction (zEvent) {
    try {
        var list = document.querySelectorAll('.card-item.col-xl-2.col-lg-3.col-sm-4.col-6');
    } catch (e) {
        console.error(e.message);
    }
    for (let item of list) {
        // console.log(item.getElementsByTagName("img")[0].getAttribute("data-src"));
        // console.log(item.getElementsByClassName("num")[0].innerHTML);
        document.write(item.getElementsByTagName("img")[0].getAttribute("data-src")," ", item.getElementsByClassName("num")[0].innerHTML,"<BR>");
    }
    const textArea = document.querySelector('body');
    console.log(textArea.innerText)
    downloadToFile(textArea.innerText, 'deck.txt', 'text/plain');
}
window.onload = function() {
    var zNode = document.createElement ('div');
    zNode.innerHTML = '<button id="myButton" type="button">'
        + 'Create TSDB</button>'
    ;
    zNode.setAttribute ('id', 'myContainer');
    document.body.appendChild (zNode);
    document.getElementById ("myButton").addEventListener (
        "click", ButtonClickAction, false
    );
};

const downloadToFile = (content, filename, contentType) => {
  const a = document.createElement('a');
  const file = new Blob([content], {type: contentType});
  a.href= URL.createObjectURL(file);
  a.download = filename;
  a.click();

	URL.revokeObjectURL(a.href);
};