HWM_Resources

Библиотека всякой мелочевки, для совместной работы других скриптов

目前為 2023-12-16 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.cn-greasyfork.org/scripts/447488/1296778/HWM_Resources.js

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

You will need to install an extension such as Tampermonkey to install this script.

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         HWM_Resources
// @namespace    http://tampermonkey.net/
// @version      1.5
// @description  Библиотека всякой мелочевки, для совместной работы других скриптов
// @author       Tags
// @include      /^https{0,1}:\/\/(www\.heroeswm\.ru|178\.248\.235\.15|my\.lordswm\.com)\/(pl_info.php*)/
// @icon         https://www.google.com/s2/favicons?sz=64&domain=heroeswm.ru
// @grant         none
// @license      CC BY-NC-SA 4.0
// ==/UserScript==

this.MercenaryElements = {
    "абразив":{
        id: "EL_42",
        art_type: "abrasive"
    }, "змеиный яд":{
        id: "EL_43",
        art_type: "snake_poison"
    }, "клык тигра":{
        id: "EL_46",
        art_type: "tiger_tusk"
    }, "ледяной кристалл":{
        id: "EL_44",
        art_type: "ice_crystal"
    }, "лунный камень":{
        id: "EL_45",
        art_type: "moon_stone"
    }, "огненный кристалл":{
        id: "EL_40",
        art_type: "fire_crystal"
    }, "осколок метеорита":{
        id: "EL_37",
        art_type: "meteorit"
    }, "цветок ведьм":{
        id: "EL_41",
        art_type: "witch_flower"
    }, "цветок ветров":{
        id: "EL_39",
        art_type: "wind_flower"
    }, "цветок папоротника":{
        id: "EL_78",
        art_type: "fern_flower"
    }, "ядовитый гриб":{
        id: "EL_38",
        art_type: "badgrib"
    },};


this.ItemCollection ={
    "item_template": {
        stats: { //параметры
            attr_attack: 2, //значение атаки
            attr_defense: 2, //значение защиты
            attr_magicpower: 1, //значение силы магии
            attr_knowledge: 1, //значение знаний
            attr_initiative: 1, //значение инициативы
            attr_fortune: 0, //значение удачи
            attr_morale: 0, //значение морали
            attr_oa: 7, //значение очков аммуниции
            additional_stats:["параметр_1","параметр_2"] //дополнительные эффекты
        },
        required_level: 15, //требуемый уррвень
        base_durability: 0, //базовая прочность
        repair_price: 20000, //цена ремонта
        is_hunting_item: false, //добывается ли предмет на охоте
        is_event_item: true, //ивентовый предмет
        is_set_part: true, //часть сета
        is_shop_item: false, //предмет из магазина
        is_shop_status:false, //предмет со статусом "из магазина"
        shop_price: 0, //цена в магазине
    },
    "ocean_eye1": {
        repair_price: 20000,
        stats: {
            attr_attack: 2,
            attr_defense: 2,
            attr_magicpower: 1,
            attr_knowledge: 1,
            attr_initiative: 1,
            attr_fortune: 0,
            attr_morale: 0,
            attr_oa: 7
        },
        required_level: 15,
        base_durability: 0,
        is_hunting_item: false,
        is_event_item: true,
        is_set_part: true,
        is_shop_item: false,
        is_shop_status:false,
        shop_price: 0,
    },
};




(function() {
    'use strict';

    if(!window.location.href.includes('pl_info'))
        return;
    const tables = Array.from(document.getElementsByClassName('wb'));
    const resourceTable = tables[tables.indexOf(tables.filter(e=>e.innerText=="Ресурсы")[0])+3]
    if(resourceTable.hasAttribute("done")){
        console.log("already processed");
        return;}
    //Вытаскиваем все доступные элементы и превращаем в объекты.
    const items = resourceTable.innerHTML.split(/&nbsp;/).filter(e => e !== "").map(s => s.replaceAll("<b>", "").replaceAll("<br>", "").replaceAll("</b>", "")).map(e => ({
        name: e.split(':')[0],
        value: e.split(':')[1],
        isMercenary: window.MercenaryElements[e.split(':')[0]]!==undefined,
    }));

    const parts = items.filter(e=>!e.isMercenary);
    const mercenary = items.filter(e=>e.isMercenary);
    //Чистим табличку
    resourceTable.innerHTML = "";

    //Записываем новую разметку
    for (let item of parts) {
        const div = Object.assign(
            document.createElement('div'), {
                innerHTML: `<div>&nbsp;&nbsp;&nbsp;&nbsp;<b>${item.name}</b>:&nbsp;${item.value}</div>`,

            });;
        div.setAttribute('ismercenary', item.isMercenary);
        div.setAttribute('name', item.name);
        resourceTable.appendChild(div);
    }
    const splitter = Object.assign(
        document.createElement('div'), {
            innerHTML: `<div name="splitter"><br></div>`,

        });;
    if(parts.length>0){
        resourceTable.appendChild(splitter);
    }
    for (let item of mercenary) {
        const div = Object.assign(
            document.createElement('div'), {
                innerHTML: `<div">&nbsp;&nbsp;&nbsp;&nbsp;<b>${item.name}</b>:&nbsp;${item.value}</div>`,

            });;
        div.setAttribute('ismercenary', item.isMercenary);
        div.setAttribute('name', item.name);
        resourceTable.appendChild(div);
    }
    resourceTable.setAttribute("done","true")
})();