Burglary Highlighter

Highlights burgarly locations that are good based on given array list below

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Burglary Highlighter
// @namespace    http://tampermonkey.net/
// @version      2024-12-25-2
// @description  Highlights burgarly locations that are good based on given array list below
// @author       olesien
// @match        https://www.torn.com/loader.php?sid=crimes*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=torn.com
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    const goodCrimes = ["Foundry", "Fertilizer Plant", "Cottage", "Beach Hut", "Lake House", "Truckyard", "Mobile Home", "Suburban Home", "Printing Works", "Funeral Directors", "Dentists' Office", "Self Storage Facility", "Post Office", "Market"];

    const run = (element) => {
        const check = () => {
            const items = element.querySelectorAll(".virtual-item");
            Array.from(items)?.forEach(async (item) => {
                console.log(item);
                const itemId = ".crimeOptionSection___hslpu";
                const name = item.querySelector(itemId);
                console.log(name);
                console.log(name.innerText);
                const crimeOption = item.querySelector(".crime-option");
                if (name && goodCrimes.find(crime => name.innerText.includes(crime))) {
                    console.log("Setting color");
                    crimeOption.style.backgroundColor = "green";
                } else {
                crimeOption.style.backgroundColor = "inherit";
                }
            });
        }
        const observer = new MutationObserver((_, observer) => {
            check();
        });
        observer.observe(element, { subtree: true, childList: true });
        check();
    }

    const observer = new MutationObserver((_, observer) => {
        //Is donate (this is default as well)
        const element = document.querySelector(".burglary-root .virtualList___noLef"); //This is the element that has all items
        if (element) {
            console.log("Checking");
            run(element);
            observer.disconnect();
        }
    });

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