PSO2 Weapon Library tool

Keep track of what weapons you have in your weapon library

目前為 2015-09-29 提交的版本,檢視 最新版本

// ==UserScript==
// @name         PSO2 Weapon Library tool
// @namespace    https://greasyfork.org/en/users/3372-nixxquality
// @version      0.4
// @description  Keep track of what weapons you have in your weapon library
// @author       nixx quality
// @match        http://pso2.swiki.jp/index.php?%E3%82%BD%E3%83%BC%E3%83%89
// @match        http://pso2.swiki.jp/index.php?%E3%83%AF%E3%82%A4%E3%83%A4%E3%83%BC%E3%83%89%E3%83%A9%E3%83%B3%E3%82%B9
// @match        http://pso2.swiki.jp/index.php?%E3%83%91%E3%83%AB%E3%83%81%E3%82%B6%E3%83%B3
// @match        http://pso2.swiki.jp/index.php?%E3%83%84%E3%82%A4%E3%83%B3%E3%83%80%E3%82%AC%E3%83%BC
// @match        http://pso2.swiki.jp/index.php?%E3%83%80%E3%83%96%E3%83%AB%E3%82%BB%E3%82%A4%E3%83%90%E3%83%BC
// @match        http://pso2.swiki.jp/index.php?%E3%83%8A%E3%83%83%E3%82%AF%E3%83%AB
// @match        http://pso2.swiki.jp/index.php?%E3%82%AC%E3%83%B3%E3%82%B9%E3%83%A9%E3%83%83%E3%82%B7%E3%83%A5
// @match        http://pso2.swiki.jp/index.php?%E3%82%AB%E3%82%BF%E3%83%8A
// @match        http://pso2.swiki.jp/index.php?%E3%83%87%E3%83%A5%E3%82%A2%E3%83%AB%E3%83%96%E3%83%AC%E3%83%BC%E3%83%89
// @match        http://pso2.swiki.jp/index.php?%E3%82%A2%E3%82%B5%E3%83%AB%E3%83%88%E3%83%A9%E3%82%A4%E3%83%95%E3%83%AB
// @match        http://pso2.swiki.jp/index.php?%E3%83%A9%E3%83%B3%E3%83%81%E3%83%A3%E3%83%BC
// @match        http://pso2.swiki.jp/index.php?%E3%83%84%E3%82%A4%E3%83%B3%E3%83%9E%E3%82%B7%E3%83%B3%E3%82%AC%E3%83%B3
                 http://pso2.swiki.jp/index.php?%E3%83%84%E3%82%A4%E3%83%B3%E3%83%9E%E3%82%B7%E3%83%B3%E3%82%AC%E3%83%B3
// @match        http://pso2.swiki.jp/index.php?%E3%83%90%E3%83%AC%E3%83%83%E3%83%88%E3%83%9C%E3%82%A6
// @match        http://pso2.swiki.jp/index.php?%E3%83%AD%E3%83%83%E3%83%89
// @match        http://pso2.swiki.jp/index.php?%E3%82%BF%E3%83%AA%E3%82%B9
// @match        http://pso2.swiki.jp/index.php?%E3%82%B8%E3%82%A7%E3%83%83%E3%83%88%E3%83%96%E3%83%BC%E3%83%84
// @grant        none
// ==/UserScript==

// setting - セッテー
var translate = true; // not implemented

/////////////////////////////////////

var tabl = document.getElementsByTagName("table")[1];
var thead = tabl.childNodes[0].childNodes[0];
var tbody = tabl.childNodes[2];

var headeritem = document.createElement("th");
headeritem.className = "style_th";
thead.insertBefore(headeritem, thead.firstChild);

function checkboxclicked()
{
    this.parentElement.style.backgroundColor = this.checked ? "green" : "red";
    localStorage[this.parentElement.parentElement.dataset.name] = this.checked;
}

for (i = 0; i < tbody.childElementCount; i++)
{
    itemname = tbody.childNodes[i].childNodes[2].firstChild.text;
    tbody.childNodes[i].dataset.name = itemname;
                           
    checkboxtd = document.createElement("td");
    checkboxtd.style.textAlign = "center";
    checkbox = document.createElement("input");
    checkbox.type = "checkbox";
    checkbox.style.width = "30px";
    checkbox.style.height = "30px";
    
    if (tbody.childNodes[i].childNodes[0].style.backgroundColor != "rgb(255, 204, 153)") // ignore extended weapon listing
    {
        checkboxtd.style.backgroundColor = "red";
        checkboxtd.appendChild(checkbox);
    }
    
    if (localStorage[itemname] == "true")
    {
        checkboxtd.style.backgroundColor = "green";
        checkbox.checked = true;
    }
    
    checkbox.addEventListener("change", checkboxclicked);
    
    tbody.childNodes[i].insertBefore(checkboxtd, tbody.childNodes[i].firstChild);
}