block-unwanted-pickpocketing-target

Hide unwanted targets from pickpocketing crime page to avoid unintended operation.

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

// ==UserScript==
// @name         block-unwanted-pickpocketing-target
// @namespace    nodelore.torn.easy-market
// @version      1.0
// @description  Hide unwanted targets from pickpocketing crime page to avoid unintended operation.
// @author       nodelore[2786679]
// @license      MIT
// @match        https://www.torn.com/loader.php?sid=crimes*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=torn.com
// @require      https://greasyfork.org/scripts/5679-wait-for-elements/code/Wait%20For%20Elements.js?version=250853
// @grant        none
// ==/UserScript==

(function(){
    const $ = window.jQuery;
    // add targets you want to block here
	const block_targets = [
		"Gang member",
		"Thug",
        "Police officer",
	]

    // add activities you want to block here
	const avoid_activities = [
		"Jogging",
        "Cycling",
        "Walking", // you can remove this to enable showing walking target
	]

	const updateCrimeOption = function(option){
	   const titleProps = $(option).find("div[class^='titleAndProps'] div");
	   const activities = $(option).find("div[class^='activity']");
	   if(titleProps.length > 0 && activities.length > 0){
		const title = titleProps.text();
		const activity = activities.contents().filter(function(){
			return this.nodeType === 3;
		}).text();
		if(block_targets.indexOf(title) !== -1){
            $(option).hide();
            console.log(`hide ${title} who is ${activity}`);
        }
        else if(avoid_activities.indexOf(activity) !== -1){
            $(option).hide();
            console.log(`hide ${title} who is ${activity}`);
        }
	   }
	}

	waitForElems({
        sel: '.crime-option',
        onmatch: updateCrimeOption
    });
})();