Torn Crimes Accessibility

readability deluxe

スクリプトをインストールするには、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         Torn Crimes Accessibility
// @namespace    http://mathias.host/
// @version      1.0.0
// @description  readability deluxe
// @author       Mathiaas [1918010]
// @match        https://www.torn.com/loader.php?sid=crimes*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=torn.com
// ==/UserScript==

(function() {
    'use strict';
    function waitForEl(selector) {
        return new Promise(resolve => {
            if(document.querySelector(selector)) {
                return resolve(document.querySelector(selector));
            }

            const observer = new MutationObserver(mutations => {
                if(document.querySelector(selector)) {
                    resolve(document.querySelector(selector));
                    observer.disconnect();
                }
            });

            observer.observe(document.body, {
                childList: true,
                subtree: true
            });
        });
    }

    waitForEl("[class^='crimeOptionSection']").then((el) => {
        console.log("Fixing accessibility.. hopefully :-)");
        let eventEnter = new Event("mouseenter"), eventLeave = new Event("mouseleave");
        let crimes = document.querySelectorAll("[class^='crimeOptionGroup'] [id^='tooltip-trigger-'");
        let tooltipPortal = null;
        crimes.forEach((e, i) => {
            if(e.querySelector("img") === null) {
                e.dispatchEvent(eventEnter);
                if(tooltipPortal === null)
                    tooltipPortal = document.querySelector(".ToolTipPortal");
                let container = e.parentNode.parentNode.querySelector("[class^='crimeOptionSection']");
                container.innerHTML += `<br />${tooltipPortal.innerText}`;
                e.dispatchEvent(eventLeave);
            }
        });
    });
})();