Easy PugMe

Adds functionality to tf2pug.me

当前为 2015-06-04 提交的版本,查看 最新版本

// ==UserScript==
// @name        Easy PugMe
// @author      deetr
// @namespace   http://deetr.me
// @description Adds functionality to tf2pug.me
// @include     http://www.tf2pug.me/
// @version     2.0
// @grant       GM_setValue
// @grant       GM_listValues
// @grant       GM_getValue
// @require     https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js
// ==/UserScript==

// Default to hide Add Soldier and Add Favs buttons
var savedvals= GM_listValues();

if (savedvals.indexOf("hideHeader") == -1){
    GM_setValue("hideHeader", false);
}
else if (GM_getValue("hideHeader")){
    $('header').hide();
}

if (savedvals.indexOf("showAddSolly") == -1){
    GM_setValue("showAddSolly", false);
}
else if (GM_getValue("showAddSolly")){
    $('#classcheckboxes').find('form').prepend('<input type="button" id="sollyButton" value = "Add Soldier" class = "dropshadow" style = "border-radius: 5px; background-color: #2A2D35; border: 0; height: 90px; margin-top: 5px; margin-bottom: 5px; margin-left: 10px; margin-right: 5px">');
    document.getElementById('sollyButton').addEventListener("click", addSoldier);
}
if (savedvals.indexOf("showAddFavs") == -1){
    GM_setValue("showAddFavs", false);
}
else if (GM_getValue("showAddFavs")){
    $('#classcheckboxes').find('form').prepend('<input type="button" id="addFavButton" value = "Add Favs" class = "dropshadow" style = "border-radius: 5px; background-color: #2A2D35; border: 0; height: 90px; margin-top: 5px; margin-bottom: 5px; margin-left: 10px; margin-right: 5px">');
    document.getElementById('addFavButton').addEventListener("click", addUpFavs);

}


$('#classcheckboxes').find('form').prepend('<input type="button" id="combatButton" value = "Add Combat" class = "dropshadow" style = "border-radius: 5px; background-color: #2A2D35; border: 0; height: 90px; margin-top: 5px; margin-bottom: 5px; margin-left: 10px; margin-right: 5px">');
document.getElementById('combatButton').addEventListener("click", addCombat);

$('#classcheckboxes').find('form').append('<input type="button" id="removeButton" value = "Remove" class = "dropshadow" style = "border-radius: 5px; background-color: #2A2D35; border: 0; height: 90px; margin-top: 5px; margin-bottom: 5px; margin-left: 10px; margin-right: 10px">');
document.getElementById('removeButton').addEventListener("click", removeAll);

$('#classcheckboxes').find('form').append('<input type="button" id="settingsButton" value = "Settings" class = "dropshadow" style = "border-radius: 5px; background-color: #2A2D35; border: 0; height: 90px; margin-top: 5px; margin-bottom: 5px; margin-left: 10px; margin-right: 10px">');
document.getElementById('settingsButton').addEventListener("click", showSettingsDialog);

$('#classcheckboxes').find('form').append('<span id = "headerToggle">▲</span>');
if (GM_getValue("hideHeader")){
    $('#headerToggle').text("▼");
    document.getElementById('headerToggle').addEventListener("click", showHeader);
}
else{
    document.getElementById('headerToggle').addEventListener("click", hideHeader);
}

function hideHeader(){
    GM_setValue("hideHeader", true);
    $('header').slideUp();
    $('#headerToggle').text("▼");
    document.getElementById('headerToggle').removeEventListener("click", hideHeader);
    document.getElementById('headerToggle').addEventListener("click", showHeader);
}

function showHeader(){
    GM_setValue("hideHeader", false);
    $('header').slideDown();
    $('#headerToggle').text("▲");
    document.getElementById('headerToggle').removeEventListener("click", showHeader);
    document.getElementById('headerToggle').addEventListener("click", hideHeader);
}

function showSettingsDialog(){
       // Make the alert	
       bootbox.alert('<table> + <tr>'
                      + "<center><h1>Easy PugMe Settings</h1>"
                      + '<td>'
                      + "<form>"
                      + '<label id = "showAddSollyLbl" class = "noselect">'
                      + '<span id = "showAddSolly" type = "checkbox"'>
                      + '</label>'
                      + '<label id = "showAddFavsLbl" class = "noselect">'
                      + '<span id = "showAddFavs" type = "checkbox"'>
                      + '</label>'
                      + "</form>"
                      + '</td>'
                      + '<td>'
                      + "test"
                      + "</center>"
                      + "</tr> </table>", setupSettings);
}

function setupSettings(){
    alert('a');
}

function addCombat() {
    alert('a');
    if (unsafeWindow.username != null) {
        if (!$("#chkScout").is(':checked')) {
            $("#chkScout").click();
        }
        if (!$("#chkPocket").is(':checked')) {
            $("#chkPocket").click();
        }
        if (!$("#chkRoamer").is(':checked')) {
            $("#chkRoamer").click();
        }
        if (!$("#chkDemo").is(':checked')) {
            $("#chkDemo").click();
        }
    } else {
        alert("You aren't logged in");
    }
}

function addSoldier() {
    if (unsafeWindow.username != null) {
        if (!$("#chkPocket").is(':checked')) {
            $("#chkPocket").click();
        }
        if (!$("#chkRoamer").is(':checked')) {
            $("#chkRoamer").click();
        }
    } else {
        alert("You aren't logged in");
    }
}

function removeAll() {
    if (unsafeWindow.game.mode == "picking") {
        alert("Cannot remove while picking in progress");
    } else if (unsafeWindow.username != null) {
        if ($("#chkScout").is(':checked')) {
            $("#chkScout").click();
        }
        if ($("#chkPocket").is(':checked')) {
            $("#chkPocket").click();
        }
        if ($("#chkRoamer").is(':checked')) {
            $("#chkRoamer").click();
        }
        if ($("#chkDemo").is(':checked')) {
            $("#chkDemo").click();
        }
        if ($("#chkMedic").is(':checked')) {
            $("#chkMedic").click();
        }
        if ($("#chkCaptain").is(':checked')) {
            $("#chkCaptain").click();
        }
    } else {
        alert("You aren't logged in");
    }
}

function addFav() {
    var newFav = $('#favDropdown').val();
    // Using booleans because GM doesn't support storing arrays :/
    if (newFav == "Scout") {
        GM_setValue("scoutFav", true);
    } else if (newFav == "Pocket") {
        GM_setValue("pocketFav", true);
    } else if (newFav == "Roamer") {
        GM_setValue("roamerFav", true);
    } else if (newFav == "Demo") {
        GM_setValue("demoFav", true);
    } else if (newFav == "Medic") {
        GM_setValue("medicFav", true);
    } else if (newFav == "Captain") {
        GM_setValue("captainFav", true);
    }
    $('#confirmSpan').text(newFav + " added to favourites").css('color', 'green');
    $('#confirmSpan').hide().css({
        visibility: "visible"
    }).fadeIn("fast").delay(1000).fadeOut("fast", function() {
        $(this).show().css({
            visibility: "hidden"
        });
    });
}

function addUpFavs() {

    if (unsafeWindow.username != null) {

        var vals = GM_listValues();

        if (vals.indexOf("scoutFav") > -1) {

            if (GM_getValue("scoutFav")) {
                if (!$("#chkScout").is(':checked')) {
                    $("#chkScout").click();
                }
            }
        }

        if (vals.indexOf("pocketFav") > -1) {
            if (GM_getValue("pocketFav")) {
                if (!$("#chkPocket").is(':checked')) {
                    $("#chkPocket").click();
                }
            }
        }

        if (vals.indexOf("roamerFav") > -1) {
            if (GM_getValue("roamerFav")) {
                if (!$("#chkRoamer").is(':checked')) {
                    $("#chkRoamer").click();
                }
            }
        }

        if (vals.indexOf("demoFav") > -1) {
            if (GM_getValue("demoFav")) {
                if (!$("#chkDemo").is(':checked')) {
                    $("#chkDemo").click();
                }
            }
        }

        if (vals.indexOf("medicFav") > -1) {
            if (GM_getValue("medicFav")) {
                if (!$("#chkMedic").is(':checked')) {
                    $("#chkMedic").click();
                }
            }
        }

        if (vals.indexOf("captainFav") > -1) {
            if (GM_getValue("captainFav")) {
                if (!$("#chkCaptain").is(':checked')) {
                    $("#chkCaptain").click();
                }
            }
        }
    } else {
        alert("You aren't logged in");
    }
}

function removeFav() {

    var oldFav = $('#favDropdown').val();
    if (oldFav == "Scout") {
        GM_setValue("scoutFav", false);
    } else if (oldFav == "Pocket") {
        GM_setValue("pocketFav", false);
    } else if (oldFav == "Roamer") {
        GM_setValue("roamerFav", false);
    } else if (oldFav == "Demo") {
        GM_setValue("demoFav", false);
    } else if (oldFav == "Medic") {
        GM_setValue("medicFav", false);
    } else if (oldFav == "Captain") {
        GM_setValue("captainFav", false);
    }
    $('#confirmSpan').text(oldFav + " removed from favourites").css('color', 'red');
    $('#confirmSpan').hide().css({
        visibility: "visible"
    }).fadeIn("fast").delay(1000).fadeOut("fast", function() {
        $(this).show().css({
            visibility: "hidden"
        });
    });
}

function clearFav() {
    GM_setValue("pocketFav", false);
    GM_setValue("roamerFav", false);
    GM_setValue("demoFav", false);
    GM_setValue("medicFav", false);
    GM_setValue("captainFav", false);
    $('#confirmSpan').text("Cleared favourites").css('color', 'red');
    $('#confirmSpan').hide().css({
        visibility: "visible"
    }).fadeIn("fast").delay(1000).fadeOut("fast", function() {
        $(this).show().css({
            visibility: "hidden"
        });
    });
}

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址