Greasy Fork is available in English.

Dropchance Combat

Adds dropchance

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Dropchance Combat
// @namespace    com.anwinity.idlepixel.sample
// @version      1.0.1
// @description  Adds dropchance
// @author       LordHC
// @license      MIT
// @match        *://idle-pixel.com/login/play*
// @grant        none
// @require https://greasyfork.org/scripts/441206-idlepixel/code/IdlePixel+.js
// ==/UserScript==
(function() {
    'use strict';

    class dropChanceCombat extends IdlePixelPlusPlugin {
        constructor() {
            super("dropChanceCombat", { // unique plugin id, "sample"
                about: { // optional, but highly recommended
                    name: GM_info.script.name,
                    version: GM_info.script.version,
                    author: GM_info.script.author,
                    description: GM_info.script.description
                }
            });
        }


        onMessageReceived(data) {
            if (data.startsWith("COMBAT_LOG=")) {
                // Removes all charachters except numbers
                function removeText(text) {
                    var num = text.replace(/[^0-9]/g, '');
                    return num;
                }
                // Checking if the its a string and not undefined
                function checking(string) {
                    if (string) {
                        return removeText(string.innerHTML);
                    }
                }
                // Adding % of chance of item
                var calculatePrecentage = function(drops, kills) {
                    var num = Math.round(drops / kills * 100 * 100) / 100;
                    if (num > 100) {
                        if (num > 999) {
                            const firstTwoNumbers = String(num).substring(0, 2);
                            const dottedNum = firstTwoNumbers.slice(0, 2) + "." + firstTwoNumbers.slice(1, 2);
                            return dottedNum + "x";
                        } else {
                            const firstTwoNumbers = String(num).substring(0, 2);
                            const dottedNum = firstTwoNumbers.slice(0, 1) + "." + firstTwoNumbers.slice(1, 2);
                            return dottedNum + "x";
                        }
                    }
                    return num + "%"
                };

                function addingMonsterDropAverage() {
                    const monsters = $("[id^='combat-log-table-']").toArray().map(el => el.getAttribute("id"));
                    // Adds the precentage on every item
                    monsters.forEach(createPrecentageItem);

                    function createPrecentageItem(item) {
                        var idCombatLogMonster = document.getElementById(item).childNodes[0]
                        var monsterKills = removeText(document.getElementById(item).childNodes[0].rows[0].childNodes[3].innerHTML);

                        for (var i = 2, row; row = idCombatLogMonster.rows[i]; i++) {
                            //iterate through rows
                            var combatLogMonsterRow = row.childNodes[2];
                            var dropsHTML = row.childNodes[3].childNodes[3]
                            var dropsRaw = checking(dropsHTML);
                            var drops = (dropsRaw = dropsRaw ?? "0");

                            var dateSpan = document.createElement('span')
                            var br = document.createElement("br");
                            dateSpan.innerHTML = calculatePrecentage(drops, monsterKills);
                            dateSpan.className = "color-grey font-small";
                            combatLogMonsterRow.appendChild(br);
                            var br2 = br.cloneNode(true);
                            combatLogMonsterRow.appendChild(br2);
                            combatLogMonsterRow.appendChild(dateSpan);
                        }
                    }

                }
                addingMonsterDropAverage();




            }

        }



    }

    const plugin = new dropChanceCombat();
    IdlePixelPlus.registerPlugin(plugin); // register the plugin

})();