Steampunk Temptress Tracker

Keep log of steampunk temptress and obtain ratio of catches to misses in GT

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Steampunk Temptress Tracker
// @version      1.0
// @description  Keep log of steampunk temptress and obtain ratio of catches to misses in GT
// @author       Rani Kheir
// @match        *www.ghost-trappers.com/fb/hunt.php*
// @match        *www.ghost-trappers.com/fb/camp.php*
// @grant        none
// @namespace https://greasyfork.org/users/4271
// ==/UserScript==



(function() {
    'use strict';
    
    // variables for catches and misses
    var catchesSPT, missesSPT;
    
    // check if HTML5 localStorage is supported
    if(typeof Storage !== "undefined") {
        
        // if it is, check if a value does NOT exists for the key-value pair steamPunkCatchCount
        
        if (!localStorage.steamPunkCatchCount) {
            // if it doesn't exist, create them
            localStorage.steamPunkCatchCount = 0;
            localStorage.steamPunkMissCount = 0;
        } else {
            // else grab values and parse into ints
            catchesSPT = parseInt(localStorage.getItem("steamPunkCatchCount"));
            missesSPT = parseInt(localStorage.getItem("steamPunkMissCount"));
        }
    }
    
    if(window.location.href.indexOf("hunt.php") > -1) {
    
    // if first string logtext contains a steampunk
    if (document.getElementsByClassName("logText")[0].innerHTML.match(/Steampunk temptress/)) {
        if (document.getElementsByClassName("logText")[0].innerHTML.match(/You have successfully/)) {
            localStorage.steamPunkCatchCount = catchesSPT + 1;
            catchesSPT = parseInt(localStorage.getItem("steamPunkCatchCount"));
        } else {
            localStorage.steamPunkMissCount = missesSPT + 1;
            missesSPT = parseInt(localStorage.getItem("steamPunkMissCount"));
        }
    }
    
    // if second string logtext contains a steampunk and is friend or auto hunt
    if (document.getElementsByClassName("logText")[1].innerHTML.match(/Steampunk temptress/) && (
    document.getElementsByClassName("logText")[1].innerHTML.match(/Your friend/) ||
    document.getElementsByClassName("logText")[1].innerHTML.match(/Your automatic trap system has/))) {
        if (document.getElementsByClassName("logText")[1].innerHTML.match(/You have successfully/)) {
            localStorage.steamPunkCatchCount = catchesSPT + 1;
            catchesSPT = parseInt(localStorage.getItem("steamPunkCatchCount"));
        } else {
            localStorage.steamPunkMissCount = missesSPT + 1;
            missesSPT = parseInt(localStorage.getItem("steamPunkMissCount"));
        }
    }
    
    }
    
    var para = document.createElement("P");
    var lineBreak = document.createElement("BR");
    var t1 = document.createTextNode("Steampunk Tracker");
    var t2 = document.createTextNode("Catches: " + catchesSPT);
    var t3 = document.createTextNode("Misses: " + missesSPT);
    var ratioSPT = (100.0*catchesSPT/(missesSPT + catchesSPT)).toFixed(2);
    var t4;
    if (isNaN(ratioSPT)) {
        t4 = document.createTextNode("");
    } else {
        t4 = document.createTextNode("Ratio: " + ratioSPT + "%");
    }
    para.appendChild(t1);
    para.appendChild(document.createElement("BR"));
    para.appendChild(t2);
    para.appendChild(document.createElement("BR"));
    para.appendChild(t3);
    para.appendChild(document.createElement("BR"));
    para.appendChild(t4);
    
    para.style.color = "white";
    
    document.getElementsByClassName("rightBanners")[0].appendChild(para);
    
})();