// ==UserScript==
// @name         Genshin Impact Data dump
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://genshin.honeyhunterworld.com/db/item/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var dataButton = document.createElement("button");
    dataButton.innerText = "Get Data";
    dataButton.setAttribute("style", "height: 3em; padding: 0.5em;background: #1e90ff;color: white; border: solid 1px gray;border-radius: 5px;");
    dataButton.addEventListener("click", function() {
        let listdiv = document.querySelector('div.items_wrap');
        let itemlist = listdiv.querySelectorAll('span.itemname');
        let outList = [];
        for (let i = 0; i < itemlist.length; i++) {
            outList.push(itemlist[i].innerText);
        }
        console.log(outList.join('\n'));
    });

    var urlButton = document.createElement("button");
    urlButton.innerText = "Get URL";
    urlButton.setAttribute("style", "height: 3em; padding: 0.5em;background: #1e90ff;color: white; border: solid 1px gray;border-radius: 5px;");
    urlButton.addEventListener("click", function() {
        let listdiv = document.querySelector('div.items_wrap');
        let itemlist = listdiv.querySelectorAll('div.itemcont > a > div > div.itempic_cont > img.itempic');
        let outList = [];
        for (let i = 0; i < itemlist.length; i++) {
            outList.push("https://genshin.honeyhunterworld.com" + itemlist[i].getAttribute("src"));
        }
        console.log(outList.join('\n'));
    });

    var dataList = document.querySelector('div.items_wrap');
    dataList.parentNode.insertBefore(dataButton, dataList);
    dataList.parentNode.insertBefore(urlButton, dataList);

})();