Torn CT Pot Notifications

Notifies large Pot games

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Torn CT Pot Notifications
// @namespace   https://www.torn.com/profiles.php?XID=2029670
// @version     1.2
// @description Notifies large Pot games
// @author      MikePence [2029670]
// @match       https://www.torn.com/christmas_town.php*
// @requires    https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// @grant       GM_notification
// @grant       window.focus
// ==/UserScript==

// Change these
var potNotificationAmount = 30;
var silentNotifications = true;

// Don't change these
var numSlots = 12 * 8;
var notifiedLarge = false;
var notifiedDone = false;

$(document).ready(function(){
    var potInterval = window.setInterval(potFunction, 100);
    function potFunction(){
        var container = $(".status-area-container").first();
        if(container.children().first().attr("class").includes("wrap")){
            notifiedDone = false;
            var wrap = container.children().first();
            if(wrap.children().first().attr("class").includes("board")){
                var board = wrap.children().first();
                var itemsWrap = board.children().eq(1);
                var potAmount = itemsWrap.children().length;
                var winPercent = Math.min(Math.floor(1000 * 3 / (numSlots - potAmount)) / 10, 100);
                var controls = wrap.children().eq(1);
                var message = controls.children().first();
                message.text("Pot is at " + potAmount + " (" + winPercent + "% chance to win)");
                if(!notifiedLarge && potAmount >= potNotificationAmount){
                    notifiedLarge = true;
                    GM_notification({
                        text: potAmount + " items",
                        title: "CT large pot",
                        silent: silentNotifications,
                        timeout: 5000,
                        onclick: function() {
                            window.focus();
                        }
                    });
                }
            }
        }
        else{
            notifiedLarge = false;
        }
        if(container.children().first().attr("class").includes("score-board")){
            if(!notifiedDone){
                notifiedDone = true;
                GM_notification({
                    text: "Made by MikePence [2029670]",
                    title: "CT pot done",
                    silent: silentNotifications,
                    timeout: 5000,
                    onclick: function() {
                        window.focus();
                    }
                });
            }
        }
    }
});