// ==UserScript==
// @name [GC | BETA] - Dailies Global Preferences Wizard
// @namespace https://greasyfork.org/en/users/1225524-kaitlin
// @match https://grundos.cafe/*
// @match https://www.grundos.cafe/*
// @version 1.2
// @author Cupkait
// @icon https://i.imgur.com/4Hm2e6z.png
// @require https://code.jquery.com/jquery-3.6.3.min.js
// @license MIT
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_registerMenuCommand
// @grant GM_addStyle
// @credits Elements of this script are possible in no small part due to anyone helping me collect html examples, find bugs, etc.
// @credits I may eventually include a list of credits, but for now - you know who you are. Thank you <3
// @description Global script that only runs relevant code on individual dailies pages.
// Run the "Set Variable" command in the menu to set up active pet redirects.
// Currently a known issue with having blank entries default to your identified main pet.
// If you leave a question blank, it just won't redirect your active pet for that daily.
// Upcoming feature(s):
// On-screen menu for setting/resetting variables.
// Setting your Wishing Well preferences.
//
//
// If I've missed a daily, I either don't have it or forgot about it - PLEASE tell me so I can add it in :D
//
//
// ==/UserScript==
$(document).ready(function () {
function setVariableValue(variableName, promptMessage) {
var currentValue = GM_getValue(variableName, "");
if (!currentValue) {
var userInput = prompt(
promptMessage +
"\n\nPet name is CASE SENSITIVE. Use proper capitalization.\nIf you have no preference, set it to match your main pet."
);
if (userInput !== "") {
GM_setValue(variableName, userInput || mainPet);
}
}
}
function checkAndSetVariables() {
setVariableValue(
"mainPet",
"What pet do you want to be active by default?\n\nNOTE: Do not leave this one blank, it is the only required value."
);
setVariableValue(
"turmyPetpet",
"Turmaculus can eat petpets. Which pet has a petpet he can safely eat?\n\nNote: If you can beat him in the BD you can get your petpet back, you will just lose any petpet levels and other progress when reattaching."
);
setVariableValue(
"questPet",
"Faerie and Kitchen quests give random stat increases. What pet do you want to receive these?"
);
setVariableValue(
"labPet",
"The lab ray can randomly change species, color, and stats. What pet do you want to use as a lab rat?"
);
setVariableValue(
"scratchcardPet",
"Scratchcards have the possibility of increasing levels. What pet do you want to receive these?"
);
setVariableValue(
"labPetpet",
"What pet has the petpet that you want to zap?"
);
setVariableValue(
"jellyPet",
"When visiting the Green Jelly your pet may turn Jelly. Which pet would you prefer this happen to?"
);
setVariableValue(
"spookyPetpet",
"Which pet has a Spooky petpet (so they can visit the toilet)?"
);
setVariableValue(
"wheelPet",
"Wheels can give random stat increases, decreases, and illnesses. What pet do you want these to affect?"
);
setVariableValue(
"employedPet",
"Some people want all job stats to stay on the same pet. If you care, which pet should they go to?"
);
setVariableValue(
"firstCoord",
"Set your first Buried Treasure coordinate. Pick a number 1-473."
);
setVariableValue(
"secondCoord",
"Set your second Buried Treasure coordinate. Pick a number 1-473."
);
}
GM_registerMenuCommand("Set Variables", function () {
checkAndSetVariables();
});
function updateLink(originalPath, updatedPath) {
const linkElement = $(`#aio_sidebar a[href="${originalPath}"]`);
if (linkElement.length > 0) {
linkElement.attr("href", updatedPath);
}
}
var mainPet = GM_getValue("mainPet", "");
var turmyPetpet = GM_getValue("turmyPetpet", "");
var questPet = GM_getValue("questPet", "");
var labPet = GM_getValue("labPet", "");
var scratchcardPet = GM_getValue("scratchcardPet", "");
var labPetpet = GM_getValue("labPetpet", "");
var jellyPet = GM_getValue("jellyPet", "");
var spookyPetpet = GM_getValue("spookyPetpet", "");
var wheelPet = GM_getValue("wheelPet", "");
var employedPet = GM_getValue("employedPet", "");
var firstCoord = GM_getValue("firstCoord", "");
var secondCoord = GM_getValue("secondCoord", "");
updateLink(
"/games/stockmarket/stocks/",
"/games/stockmarket/stocks/?view_all=True"
);
updateLink(
"/pirates/buriedtreasure/",
`/pirates/buriedtreasure/play/?${firstCoord},${secondCoord}`
);
updateLink(
"/medieval/symolhole/",
`/setactivepet/?pet_name=${turmyPetpet}&redirect=/medieval/symolhole/`
);
updateLink(
"/medieval/turmaculus/",
`/setactivepet/?pet_name=${turmyPetpet}&redirect=/medieval/turmaculus/`
);
updateLink(
"/faerieland/springs/",
`/setactivepet/?pet_name=${questPet}&redirect=/faerieland/springs/`
);
updateLink(
"/island/kitchen/",
`/setactivepet/?pet_name=${questPet}&redirect=/island/kitchen/`
);
updateLink(
"/faerieland/quests/",
`/setactivepet/?pet_name=${questPet}&redirect=/faerieland/quests/`
);
updateLink(
"/desert/shrine/",
`/setactivepet/?pet_name=${questPet}&redirect=/desert/shrine/`
);
updateLink(
"/halloween/toilet/",
`/setactivepet/?pet_name=${spookyPetpet}&redirect=/halloween/toilet/`
);
updateLink(
"/winter/kiosk/",
`/setactivepet/?pet_name=${scratchcardPet}&redirect=/winter/kiosk/`
);
updateLink(
"/halloween/kiosk/",
`/setactivepet/?pet_name=${scratchcardPet}&redirect=/halloween/kiosk/`
);
updateLink(
"/desert/kiosk/",
`/setactivepet/?pet_name=${scratchcardPet}&redirect=/desert/kiosk/`
);
updateLink(
"/medieval/brightvale/wheel/",
`/setactivepet/?pet_name=${wheelPet}&redirect=/medieval/brightvale/wheel/`
);
updateLink(
"/faerieland/wheel/",
`/setactivepet/?pet_name=${wheelPet}&redirect=/faerieland/wheel/`
);
updateLink(
"/prehistoric/wheel/",
`/setactivepet/?pet_name=${wheelPet}&redirect=/prehistoric/wheel/`
);
updateLink(
"/halloween/wheel/",
`/setactivepet/?pet_name=${wheelPet}&redirect=/halloween/wheel/`
);
updateLink(
"/jelly/greenjelly/",
`/setactivepet/?pet_name=${jellyPet}&redirect=/jelly/greenjelly/`
);
updateLink(
"/winter/snowager/",
`/setactivepet/?pet_name=${mainPet}&redirect=/winter/snowager/approach/`
);
updateLink("/jelly/jelly/", "/jelly/take_jelly/");
updateLink(
"/prehistoric/plateau/omelette/",
`/prehistoric/plateau/omelette/approach/`
);
updateLink("/desert/fruitmachine/", `/desert/fruitmachine2/`);
updateLink("/faerieland/tdmbgpop/", `/faerieland/tdmbgpop/visit/`);
updateLink("/island/tombola/", `/island/tombola/play`);
updateLink("/neoschool/courses/", `/neoschool/course/`);
//updateLink('', '');
//updateLink('', '');
// Placeholder template to add other link updates...
//
if (window.location.href.endsWith("/stocks/?view_all=True")) {
highlightRows() }
// SPOOKY TOILET - Press enter to take a swirl. 🤢
if (window.location.href.endsWith("/halloween/toilet/")) {
const submitButton = $('input[name="jump"].form-control.half-width');
if (submitButton.length > 0) {
submitButton.val("Press Enter or click here to dive in!");
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.click();
}
});
}
}
// DEADLY DICE - Press enter to roll the dice.
if (window.location.href.endsWith("worlds/roo/deadlydice/")) {
const submitButton = $('button[type="submit"].form-control');
if (submitButton.length > 0) {
submitButton.text("Press Enter or click here to play!");
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.click();
}
})
}
}
// WHEELS -- Enter to spin, prize displayed automatically.
if (
window.location.href.endsWith("/halloween/wheel/") ||
window.location.href.endsWith("/prehistoric/wheel/") ||
window.location.href.endsWith("/faerieland/wheel/")
) {
const submitButton = $('input[type="submit"][name="spin"]');
if (submitButton.length > 0) {
submitButton.val("Press Enter or click here to spin!");
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.click();
}
});
} else {
$("#spinning").hide();
$("#prize-container").show();
}
}
// TEST YOUR STRENGTH - Displays prize immediately after you click the button.
if (window.location.href.endsWith("/halloween/strtest/")){
const strPrize = $('#modal-body > div > p:nth-child(3)');
if (strPrize.length > 0 && strPrize.text().trim() !== "") {
const prizeText = strPrize.text().trim();
const styledPrize = $('<div></div>').text(prizeText).css({
'color': '#ff9900',
'font-size': '18px',
'font-weight': 'bold',
'margin-bottom': '10px'
});
$('#game-container').prepend(styledPrize);
} else console.log("come back later")
}
// KNOWLEDGE WHEEL - Enter to spin, prize displayed automatically.
if (window.location.href.endsWith("/medieval/brightvale/wheel/")) {
const submitButton = $('input[type="submit"].form-control.half-width');
if (submitButton.length > 0) {
submitButton.val("Press Enter or click here to spin!");
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.click();
}
});
} else {
$("#spinning").hide();
$("#prize-container").show();
}
}
// TIKI TOUR - Display exact cost to tour all pets so you don't actually spend all your NP
if (window.location.href.endsWith('/island/tikitours/')) {
const petCount = ((document.querySelectorAll('.userLookupPet').length) * 1000).toLocaleString();
const tourAll = document.querySelector("button[name='all_pets']");
tourAll.onclick = function() {
return confirm(`Do you really want to spend ${petCount} NP to take all of your pets on tour?`);
};
}
// SYMOL HOLE - Method is randomized. Press enter to enter the hole, slow-mode for results is disabled.
if (window.location.href.endsWith("/medieval/symolhole/")) {
const hole = $("#waiting");
if (!hole.length) {
const options = $("#enter_action option:not([disabled])");
const randomIndex = Math.floor(Math.random() * options.length);
options.eq(randomIndex).prop("selected", true);
const submitButton = $('input[type="submit"][name="enter"]');
if (submitButton.length) {
submitButton.val("Press Enter or click here to enter!");
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.click();
}
});
}
} else if (hole !== undefined) {
hole.hide();
$("#wait-for-me").show();
}
}
// HEALING SPRINGS -- Press enter to heal.
if (window.location.href.endsWith("/faerieland/springs/")) {
const submitButton = $('input[type="submit"].form-control.half-width');
if (submitButton.length > 0) {
submitButton.val("Press Enter or click here to heal!");
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.click();
}
});
}
}
// FISHING - Press enter to fish. If you unlocked free bulk fishing, this will be prioritized.
if (window.location.href.endsWith("/water/fishing/")) {
let getCost = $("main p:eq(2)").text();
if (
getCost ===
"You can also choose to send all of your eligible pets fishing at the same time for FREE!!"
) {
const submitButton = $(
'input[type="submit"][value="Fish with Everyone!"]'
);
if (submitButton.length) {
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.click();
}
});
}
} else {
const submitButton = $('input[type="submit"][value="Reel in Your Line"]');
if (submitButton.length) {
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.click();
}
});
}
}
}
// MERRY GO ROUND - Calculate total and lets you ride by pressing enter.
if (window.location.href.endsWith("/roo/merrygoround/")) {
const sadPetCount = document.querySelectorAll('.mgr__pet .med-image[src*="sad"]').length;
const totalCost = sadPetCount > 0 ? 50 + 100 * (sadPetCount - 1) : 0;
const totalVisits = Math.ceil(sadPetCount / 6);
if (sadPetCount > 0) {
const costDetails = document.createElement('div');
costDetails.style.marginBottom = "40px";
costDetails.innerHTML = `<h3>${sadPetCount} pets can be cheered up for ${totalCost} NP.</h3> <p>Cheering up everyone will take ${totalVisits} rides.</p> <strong>Press enter to start the ride!</strong>`;
const userPetList = document.getElementById('userPetList');
userPetList.parentNode.insertBefore(costDetails, userPetList);
}
const submitButton = $('input[type="submit"][value*="Cheer Up"].form-control.half-width');
if (submitButton.length > 0) {
submitButton.val("Press enter or click here to ride!!");
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.click();
}
});
}}
// GREEN JELLY - Enter to approach.
if (window.location.href.endsWith("/jelly/greenjelly/")) {
const submitButton = $('input[type="submit"].form-control.half-width');
if (submitButton.length > 0) {
submitButton.val("Press Enter or click here to visit!");
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.click();
}
});
}
}
// GRUMPY OLD KING - Enter to submit, known avatar elements applied
if (window.location.href.endsWith("/medieval/grumpyoldking/")) {
const submitButton = $('input[type="submit"][name="joke"]');
const againButton = $('input[type="button"][value="Try Again?"]');
if (againButton.length > 0) {
againButton.val("Press Enter or click to tell another!");
$(document).keydown(function (event) {
if (event.key === "Enter") {
againButton.click();
}
});
} else if (submitButton.length > 0) {
generateJoke();
$("#question1").val("What");
$("#question2").val("do");
$("#question3").val("you do if");
$("#question4").val("*Leave blank*");
$("#question5").val("fierce");
$("#question6").val("Grundos");
$("#question7").val("*Leave blank*");
$("#question8").val("has eaten too much");
$("#question9").val("*Leave blank*");
$("#question10").val("tin of olives");
submitButton.val("Press Enter or click here to joke!");
$(document).keydown(function (event) {
if (event.key === "Enter") {
submitButton.click();
}
});
} else {
console.log("You already told two jokes.");
}
}
// WISE OLD KING - Enter to submit, inserts known required avatar variables & randomly generates the remaining values.
if (window.location.href.endsWith("/medieval/wiseking/")) {
generateJoke();
$("#wisdom2").val("pride");
$("#wisdom6").val("nugget");
const submitButton = $('input[type="submit"][name="impress"]');
if (submitButton.length > 0) {
submitButton.val("Press Enter or click here to impress!");
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.click();
}
});
}
}
// COLTZANS SHRINE - Enter to visit.
if (window.location.href.endsWith("/desert/shrine/")) {
const submitButton = $(".center").find('input[type="submit"].form-control');
if (submitButton.length === 2) {
submitButton.first().val("Press Enter or click here to visit!");
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.first().click();
}
});
}
}
// LOTTERY - Enter to use Quick Pick.
if (window.location.href.endsWith("/games/lottery/")) {
const submitButton = $('input[type="submit"].form-control.half-width');
if (submitButton.length > 0) {
submitButton.val("Press Enter or click here to buy 20!");
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.click();
}
});
}
}
// BANK INTEREST - Enter to collect bank interest.
if (window.location.href.endsWith("/bank/")) {
const submitButton = $('input[type="submit"].form-control.half-width');
const submitButtonValue = submitButton.val();
if (submitButtonValue.includes ("Collect Interest")) {
console.log("script active")
const newValue = "Click/Enter to " + submitButtonValue;
submitButton.val(newValue);
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.first().click();
}
});
}
}
// TURMACULUS - Enter to try and wake.
if (window.location.href.endsWith("/medieval/turmaculus/")) {
const options = $("#wakeup option:not([disabled])");
const randomIndex = Math.floor(Math.random() * options.length);
options.eq(randomIndex).prop("selected", true);
const submitButton = $('input[type="submit"][name="wake"]');
if (submitButton.length > 0) {
submitButton.val("Press Enter or click here to enter!");
$(document).on("keydown", function (event) {
if (event.key === "Enter") {
submitButton.click();
}
});
}
}
// Winter Kiosk - B to buy, S to scratch.
if (window.location.href.endsWith("/winter/kiosk/")) {
const buyButton = $('button.form-control.half-width');
const scratchButton = $('#page_content > main > form > input.form-control');
if (buyButton.length > 0) {
buyButton.text('Press "b" or click to buy a scratchcard.');
$(document).on("keydown", function (event) {
if (event.key === "b") {
buyButton.click();
}
});
}
if (scratchButton.length > 0) {
const selectCard = $('select[name="card"]');
const options = $('select[name="card"] option:gt(0)');
console.log(options)
const randomIndex = Math.floor(Math.random() * options.length);
options.eq(randomIndex).prop("selected", true);
scratchButton.val('Press "s" or click to begin scratching.');
$(document).on("keydown", function (event) {
if (event.key === "s") {
scratchButton.click();
}
});
}
}
// Deserted Kiosk - B to buy, S to scratch.
if (window.location.href.endsWith("/halloween/kiosk/")) {
const buyButton = $('button.form-control.half-width');
const scratchButton = $('input[type="submit"].form-control.half-width');
if (buyButton.length > 0) {
buyButton.text('Press "b" or click to buy a scratchcard.');
$(document).on("keydown", function (event) {
if (event.key === "b") {
buyButton.click();
}
});
}
if (scratchButton.length > 0) {
const selectCard = $('select[name="card"]');
const options = $('select[name="card"] option:gt(0)');
console.log(options)
const randomIndex = Math.floor(Math.random() * options.length);
options.eq(randomIndex).prop("selected", true);
scratchButton.val('Press "s" or click to begin scratching.');
$(document).on("keydown", function (event) {
if (event.key === "s") {
scratchButton.click();
}
});
}
}
// Desert Kiosk - B to buy, S to scratch.
if (window.location.href.endsWith("/desert/kiosk/")) {
const buyButton = $('button.form-control.half-width');
const scratchButton = $('input.form-control.half-width');
if (buyButton.length > 0) {
buyButton.text('Press "b" or click to buy a scratchcard.');
$(document).on("keydown", function (event) {
if (event.key === "b") {
buyButton.click();
}
});
}
if (scratchButton.length > 0) {
const selectCard = $('select[name="card"]');
const options = $('select[name="card"] option:gt(0)');
console.log(options)
const randomIndex = Math.floor(Math.random() * options.length);
options.eq(randomIndex).prop("selected", true);
scratchButton.val('Press "s" or click to begin scratching.');
$(document).on("keydown", function (event) {
if (event.key === "s") {
scratchButton.click();
}
});
}
}
// GARDEN - Visualize if count is low.
if (window.location.href.endsWith("/garden/")) {
const pickButton = $('input[name="pick"].form-control.half-width');
const tendButton = $('input[name="tend"].form-control.half-width');
const donateButton = $('input[type="button"].form-control.half-width');
if (pickButton.length > 0) {
pickButton.val(`Press "p" or click here to pick!`);
$(document).on("keydown", function (event) {
if (event.key === "p") {
pickButton.click();
}
});
}
if (tendButton.length > 0) {
tendButton.val(`Press "t" to tend the garden.`);
$(document).on("keydown", function (event) {
if (event.key === "t") {
tendButton.click();
}
});
}
if (donateButton.length > 0) {
donateButton.val(`Press "d" to donate to Bert.`);
$(document).on("keydown", function (event) {
if (event.key === "d") {
donateButton.click();
}
});
}
const gardenCount = parseInt($('#page_content').find('p.center').text().replace(/,/g, '').match(/\d+/)[0]) || null;
const gardenMsg = $('#page_content > div > p.center');
$('#page_content > div > p:nth-child(4)').remove();
$('#page_content > div > p:nth-child(6)').remove();
$('#page_content > div > p:nth-child(4)').remove();
if (gardenCount < 1000) {
$('<div>')
.text("Oh no! This garden needs more inventory to be able to award you the highest tier of prizes. Consider donating supplies before picking!")
.css({
"margin-top": "10px",
"font-weight": "bold",
"color": "#f45957",
"font-size": "18px",
"text-align": "center"
})
.insertBefore(gardenMsg);
} else if (gardenCount > 999) {
$('<div>')
.text("This garden is doing great, but don't forget - in order to give as much as you take, you should donate at least 300 points per month! 🍃")
.css({
"margin-top": "10px",
"font-weight": "bold",
"color": "#538bf9",
"font-size": "14px",
"text-align": "center"
})
.insertBefore(gardenMsg);
}
function nextGarden(offset) {
const gardens = [...[...document.querySelectorAll('p')].find(p => p.textContent.includes('My Guilds:')).querySelectorAll('a')].map(a => a.href);
const active = [...document.querySelectorAll('p')].find(p => p.textContent.includes('Guild Home')).querySelectorAll('a')[1].href;
const index = gardens.indexOf(active);
const next = (index + offset + gardens.length) % gardens.length;
window.location.href = gardens[next];
}
}
// NEOSCHOOL - If you're on a course, go straight to it. If you aren't, go to the course menu.
if (window.location.href.endsWith("/neoschool/course/")) {
const error = $(".errorpage");
if (error.length > 0) {
window.location.replace("/neoschool/courses/");
}
}
});
function highlightRows() {
var table = document.querySelector('.stock-table');
if (!table) {
console.log("Table not found on this page.");
return;
}
var rows = Array.from(table.querySelectorAll('tr'));
// Display buyable stocks
var curr15Rows = [];
rows.forEach(function(row) {
var cells = row.querySelectorAll('td');
if (cells.length >= 6) {
var currCell = cells[5];
if (currCell.textContent.trim() === "15") {
curr15Rows.push(row);
}
}
});
if (curr15Rows.length === 0) {
// Display a message if there are no buyable stocks
var messageDiv = document.createElement('div');
messageDiv.textContent = "😭 There are no buyable stocks at this time.";
messageDiv.style.fontSize = '24px';
messageDiv.style.textAlign = 'center';
table.parentNode.insertBefore(messageDiv, table);
} else {
curr15Rows.forEach(function(row) {
row.parentNode.removeChild(row);
table.insertBefore(row, table.firstChild);
var cells = row.querySelectorAll('td');
cells.forEach(function(cell) {
cell.style.backgroundColor = 'yellow';
});
});
}
}