Greasy Fork

Greasy Fork is available in English.

[GC] - Kadoatery Details Helper

Checks if feeding a kad was successful and logs the results to pass through a Discord webhook.

当前为 2024-01-25 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.icu/scripts/485575/1317111/%5BGC%5D%20-%20Kadoatery%20Details%20Helper.js

// ==UserScript==
// @name        [GC] - Kadoatery Details Helper
// @namespace   http://greasyfork.icu/en/users/1225524-kaitlin
// @match       https://www.grundos.cafe/games/kadoatery/feed_kadoatie/*
// @version     1.4.3
// @author      Cupkait
// @license     MIT
// @description Checks if feeding a kad was successful and logs the results to pass through a Discord webhook.
// ==/UserScript==

function GrabKadoatieDetails() {
	var fullText = $('.center').html();

	const errorPage = $('.errorpage');
	if (errorPage.length > 0) {
		const errorText = errorPage.text();

		if (errorText.includes("has already been fed")) {
			console.log(
				'Too slow, someone else got to that kad first.');
		} else if (errorText.includes("wait a bit")) {
			console.log('You already fed a kad, try again later.');
		}
	} else {
		const elementOne = $('.center p').eq(0);
		const elementTwo = $('.center p').eq(1);
		const elementThree = $('.center p').eq(2);
		const kadType = $('.center p').eq(3);
		const elementFive = $('.center p').eq(4);

		const userName = /user=(.*?)"/g.exec(document.body.innerHTML)[
			1];
		const kadImage = elementTwo.find('img').eq(0).attr('src');
		const kadName = elementOne.find('b').eq(0).text();
		const kadBlurb = elementTwo.find('strong').eq(0).text();
		const kadPaint = kadImage.split('/').pop().replace(
			'_happy.gif', '');

		let relicStatus = false;
		let kadCount = kadType.find('strong').eq(0).text();

		if (kadType.text().includes("particularly grateful")) {
			kadCount = elementFive.find('strong').eq(0).text();
			console.log(
				`${userName} fed ${kadName} the ${kadPaint} Kadoatie as number ${kadCount} and got a relic!`
				);
			relicStatus = true;
		} else {
			console.log(
				`${userName} fed ${kadName} the ${kadPaint} Kadoatie as number ${kadCount}!`
				);
		}

		const colorMapping = {
			green: "#A6D376",
			yellow: "#FFFF67",
			pink: "#FF9BCD",
			spotted: "#F1BE26",
			rainbow: "#C961FC",
			white: "#DEE9F3",
			blue: "#85A5E7",
			island: "#0F11C8",
		};

		const barColor = colorMapping[kadPaint.toLowerCase()] ||
			"#FFFFFF"; // Default to white if not found

		return {
			userName,
			kadName,
			kadImage,
			kadBlurb,
			kadPaint,
			kadCount,
			relicStatus,
			barColor
		};
	}
}