ww test

test

Dieses Skript sollte nicht direkt installiert werden. Es handelt sich hier um eine Bibliothek für andere Skripte, welche über folgenden Befehl in den Metadaten eines Skriptes eingebunden wird // @require https://update.greasyfork.org/scripts/487616/1329315/ww%20test.js

const winnerTable = $("table > tbody > tr").find("td.bg-liteyellow.center");
var recentWishes = [];
let wishList = GM_getValue('wishList', [])
let donationAmount = GM_getValue('donationAmount');

winnerTable.each((index, element) => {
  if (index % 3 === 2 && recentWishes.length < 14) {
    recentWishes.push($(element).text());
  }
});

let donation = document.querySelector('[name="donation"]');
donation.value = donationAmount;

for (var wish in wishList) {
    var currentWish = wishList[wish];
    if (!currentWish) {
        defaultWish = "";
        break;
    }
    var wishLowerCase = currentWish.toLowerCase();
    if (!recentWishes.some(recentWish => recentWish.toLowerCase() === wishLowerCase)) {
        defaultWish = currentWish;
        break;
    }
}

$('[name="wish"]').val(defaultWish);

const buttonContainer = document.createElement('div');
buttonContainer.id = 'wrapContainer';

const settingsButton = document.createElement('button');
settingsButton.textContent = 'Wish Settings';
settingsButton.id = 'wrapSettings';

const popoutMenu = document.createElement('div');
popoutMenu.id = 'wrapMenu';

const Button1 = document.createElement('button');
Button1.textContent = 'Set Wishes';
Button1.id = 'functionButton';
popoutMenu.appendChild(Button1);

const Button2 = document.createElement('button');
Button2.textContent = 'Set Default Donation';
Button2.id = 'functionButton';
popoutMenu.appendChild(Button2);

$(Button2).on('click', setDefaultDonation);
$(Button1).on('click', setDefaultWishList);

function createpopoutMenu() {
    buttonContainer.appendChild(settingsButton);
    buttonContainer.appendChild(popoutMenu);
    $('#sb_edge').append(buttonContainer);

    $(settingsButton).on('click', function() {
        $(popoutMenu).fadeToggle(150);
    });

    return buttonContainer;
}

createpopoutMenu();

function setDefaultDonation() {
    var currentDonationAmt = GM_getValue("donationAmount");
    var donationAmt = prompt("How many Neopoints do you want to donate per wish? Only enter the numbers, no comma or letters.\n\nNote: Any wish below 21 isn't eligible to win.", currentDonationAmt);

    if (donationAmt === null) {
        console.log("Donation amount not updated. Cancelled by user.");
        return; // Exit the function if user clicks cancel
    }

    if ($.isNumeric(donationAmt) && parseInt(donationAmt) >= 21) {
        GM_setValue("donationAmount", donationAmt);
        console.log("Donation amount updated: " + donationAmt);
    } else {
        alert("Please enter numbers only, 21 is the minimum.");
        setDefaultDonation();
    }
}

function setDefaultWishList() {
    var storedWishList = GM_getValue("wishList", { firstWish: "", secondWish: "" });

    var firstWishInput = prompt("What do you want your default wish to be?", storedWishList.firstWish);
    if (firstWishInput !== null) {
        storedWishList.firstWish = firstWishInput;

        var secondWishInput = prompt("If your default has been won too recently, what do you want to set as a backup wish? If you'd rather skip wishing or decide later, leave this blank.", storedWishList.secondWish);
        if (secondWishInput !== null) {
            storedWishList.secondWish = secondWishInput;

            var thirdWishInput = prompt("If both your default and backup wish has been won too recently, what do you want to set as a backup wish? If you'd rather skip wishing or decide later, leave this blank.", storedWishList.thirdWish);
            if (thirdWishInput !== null) {
                storedWishList.thirdWish = thirdWishInput;
            }
        }

        // Save the updated wish list
        GM_setValue("wishList", storedWishList);
    }
}