// ==UserScript==
// @name IdlePixel Completionist Tweaks
// @namespace godofnades.idlepixel
// @version 1.1.2
// @description Adds some additional functionality to the completionist screen.
// @author GodofNades
// @license MIT
// @match *://idle-pixel.com/login/play*
// @grant none
// @require https://greasyfork.org/scripts/441206-idlepixel/code/IdlePixel+.js?anticache=20220905
// ==/UserScript==
(function() {
'use strict';
let completeStart = true;
let pendingStart = true;
let stats = {
weight: {
total: 0,
pending: 0,
completed: 0,
},
categoryCount: {
pending: 0,
completed: 0,
},
completionCount: {
total: 0,
pending: 0,
completed: 0,
},
brewingCount: {
total: 0,
pending: 0,
completed: 0,
},
combatCount: {
total: 0,
pending: 0,
completed: 0,
},
cookingCount: {
total: 0,
pending: 0,
completed: 0,
},
farmingCount: {
total: 0,
pending: 0,
completed: 0,
},
fishingCount: {
total: 0,
pending: 0,
completed: 0,
},
gatheringCount: {
total: 0,
pending: 0,
completed: 0,
},
inventionCount: {
total: 0,
pending: 0,
completed: 0,
},
miningCount: {
total: 0,
pending: 0,
completed: 0,
},
miscCount: {
total: 0,
pending: 0,
completed: 0,
},
orbCount: {
total: 0,
pending: 0,
completed: 0,
},
toolCount: {
total: 0,
pending: 0,
completed: 0,
},
skillCount: {
total: 0,
pending: 0,
completed: 0,
},
woodcuttingCount: {
total: 0,
pending: 0,
completed: 0,
}
}
const cookTimes = {
"dotted_salad": 12,
"chocolate_cake": 15,
"lime_leaf_salad": 18,
"golden_apple": 21,
"banana_jello": 24,
"orange_pie": 28,
"pancakes": 30,
"coconut_stew": 40,
"dragon_fruit_salad": 60,
"potato_shake": 80,
"carrot_shake": 88,
"beet_shake": 100,
"broccoli_shake": 120,
};
let completeNode;
let pendingNode;
let originalNodes = [];
class UITweaksPlugin extends IdlePixelPlusPlugin {
constructor() {
super("completionist-tweaks", {
about: {
name: GM_info.script.name + " (ver: " + GM_info.script.version + ")",
version: GM_info.script.version,
author: GM_info.script.author,
description: GM_info.script.description
},
/*config: [
{
label: "------------------------------",
type: "label"
},
{
label: "General Stuff",
type: "label"
},
{
label: "------------------------------",
type: "label"
},
{
id: "font",
label: "Primary Font",
type: "select",
options: FONTS,
default: FONT_DEFAULT
}
]*/
});
}
resetStats() {
stats = {
weight: {
total: 0,
pending: 0,
completed: 0,
},
categoryCount: {
pending: 0,
completed: 0,
},
completionCount: {
total: 0,
pending: 0,
completed: 0,
},
brewingCount: {
total: 0,
pending: 0,
completed: 0,
},
combatCount: {
total: 0,
pending: 0,
completed: 0,
},
cookingCount: {
total: 0,
pending: 0,
completed: 0,
},
farmingCount: {
total: 0,
pending: 0,
completed: 0,
},
fishingCount: {
total: 0,
pending: 0,
completed: 0,
},
gatheringCount: {
total: 0,
pending: 0,
completed: 0,
},
inventionCount: {
total: 0,
pending: 0,
completed: 0,
},
miningCount: {
total: 0,
pending: 0,
completed: 0,
},
miscCount: {
total: 0,
pending: 0,
completed: 0,
},
orbCount: {
total: 0,
pending: 0,
completed: 0,
},
toolCount: {
total: 0,
pending: 0,
completed: 0,
},
skillCount: {
total: 0,
pending: 0,
completed: 0,
},
woodcuttingCount: {
total: 0,
pending: 0,
completed: 0,
}
}
}
firstNodeCheck() {
completeStart = true;
pendingStart = true;
document.querySelector("#panel-completionist-content").childNodes.forEach(data => {
if(data.innerHTML.includes('check.png')) {
if (completeStart) {
completeNode= data;
completeStart = false;
}
}
else if (data.innerHTML.includes('x.png')) {
if(pendingStart) {
pendingNode = data;
pendingStart = false;
}
}
});
}
buildContainers() {
originalNodes = Array.from(document.querySelector("#panel-completionist-content").childNodes);
const pendingLabelDiv = document.createElement('div');
pendingLabelDiv.id = 'pendingLabelContainer'
pendingLabelDiv.innerHTML = `
<div id="pendingLabel" style="font-size: 2em">
<span id="pendingText">STILL NEEDED</span>
<span id="pendingCount">()</span>
<br>
<span style="font-size: 0.5em">Pending Weight:</span>
<span id="pendingWeight" style="font-size: 0.5em">(Loading)</span>
</div>
<hr>
`;
document.querySelector("#panel-completionist-content").insertBefore(pendingLabelDiv, pendingNode);
// Define an array of categories and their labels
const categories = [
{ id: 'unknown', label: 'UNKNOWN' },
{ id: 'brewing', label: 'BREWING' },
{ id: 'combat', label: 'COMBAT' },
{ id: 'cooking', label: 'COOKING' },
{ id: 'farming', label: 'FARMING' },
{ id: 'fishing', label: 'FISHING' },
{ id: 'gathering', label: 'GATHERING' },
{ id: 'invention', label: 'INVENTION' },
{ id: 'mining', label: 'MINING' },
{ id: 'misc', label: 'MISCELLANEOUS' },
{ id: 'orb', label: 'ORBS' },
{ id: 'skills', label: 'SKILLS' },
{ id: 'tools', label: 'TOOLS' },
{ id: 'woodcutting', label: 'WOODCUTTING' }
];
const pendingContainer = document.getElementById('pendingLabelContainer');
// Loop through categories and create the corresponding div elements
categories.forEach(category => {
const categoryDiv = document.createElement('div');
categoryDiv.id = `pending${category.id}Container`;
const categoryDivInner = document.createElement('div');
categoryDivInner.id = `pending${category.id}ContainerInner`;
// Create a button to toggle visibility
const toggleButton = document.createElement('button');
toggleButton.innerHTML = `<br>`
toggleButton.textContent = 'Hide';
toggleButton.addEventListener('click', () => {
const contentDiv = document.getElementById(`pending${category.id}ContainerInner`);
if (contentDiv.style.display === 'none') {
contentDiv.style.display = '';
toggleButton.textContent = 'Hide';
} else {
contentDiv.style.display = 'none';
toggleButton.textContent = 'Show';
}
});
categoryDiv.innerHTML = `
<div id="pendingLabel" style="font-size: 1.25em"></div>
<span>${category.label} NEEDED</span>
<span id="pending${category.id}Div-counts"></span>
<br>
`;
categoryDiv.appendChild(toggleButton);
categoryDiv.appendChild(categoryDivInner);
pendingContainer.appendChild(categoryDiv);
});
const completeLabelDiv = document.createElement('div');
completeLabelDiv.id = 'completedLabelContainer'
completeLabelDiv.innerHTML = `
<hr>
<div id="completedLabel" style="font-size: 2em">
<span id="completedText">COMPLETED</span>
<span id="completedCount">()</span>
<br>
<span style="font-size: 0.5em">Completed Weight:</span>
<span id="completedWeight" style="font-size: 0.5em">(Loading)</span>
</div>
<hr>
`;
document.querySelector("#panel-completionist-content").insertBefore(completeLabelDiv, completeNode);
const completedContainer = document.getElementById('completedLabelContainer');
// Loop through categories and create the corresponding div elements
categories.forEach(category => {
const categoryDiv = document.createElement('div');
categoryDiv.id = `completed${category.id}Container`;
const categoryDivInner = document.createElement('div');
categoryDivInner.id = `completed${category.id}ContainerInner`;
// Create a button to toggle visibility
const toggleButton = document.createElement('button');
toggleButton.innerHTML = `<br>`
toggleButton.textContent = 'Hide';
toggleButton.addEventListener('click', () => {
const contentDiv = document.getElementById(`completed${category.id}ContainerInner`);
if (contentDiv.style.display === 'none') {
contentDiv.style.display = '';
toggleButton.textContent = 'Hide';
} else {
contentDiv.style.display = 'none';
toggleButton.textContent = 'Show';
}
});
categoryDiv.innerHTML = `
<div id="completedLabel" style="font-size: 1.25em"></div>
<span>${category.label} COMPLETED</span>
<span id="completed${category.id}Div-counts"></span>
<br>
`;
categoryDiv.appendChild(toggleButton);
categoryDiv.appendChild(categoryDivInner);
completedContainer.appendChild(categoryDiv);
});
}
findLowestLevelDivElementWithText(container, text) {
const divElements = container.querySelectorAll('.completionist-entry'); // Assume a common class for these divs
let lowestLevelElement = null;
divElements.forEach((element) => {
if (element.textContent.includes(text)) {
lowestLevelElement = element;
//console.log(lowestLevelElement.innerHTML);
}
});
return lowestLevelElement;
}
updateProgress() {
const vars = {};
const container = document.getElementById('panel-completionist');
const achievment = Achievements.completionist_data;
achievment.forEach((achiev, index) => {
if (achiev[1].startsWith("max_")) {
let baseElement = achiev[1].split('_')[1];
vars[baseElement + "_xp"] = IdlePixelPlus.getVarOrDefault(baseElement + "_xp", 0, "int");
} else {
vars[achiev[1]] = IdlePixelPlus.getVarOrDefault(achiev[1], 0, "int");
let baseText = achiev[0];
if(baseText === null) {
baseText = achiev[1].replaceAll("_"," ");
}
if(!baseText.startsWith('All')) {
const lowestLevelElement = this.findLowestLevelDivElementWithText(container, baseText);
const imgSrc = "<" + lowestLevelElement.innerHTML.split('<')[1];
if (lowestLevelElement) {
const newContent = document.createElement('div');
newContent.innerHTML = imgSrc + lowestLevelElement.textContent + ' (' + vars[achiev[1]] + "/" + achiev[2] + ')';
lowestLevelElement.innerHTML = newContent.innerHTML;
}
}
}
});
}
updateCompletetionist() {
this.resetStats();
this.firstNodeCheck();
this.buildContainers();
//console.log(originalNodes);
originalNodes.forEach(data => {
let weight = parseInt(data.title.replace('Weight: ', ''));
if(data.innerHTML.includes('check.png')) {
data.style.backgroundColor = 'darkgreen'
data.style.color = 'white'
stats.weight.completed += weight;
stats.weight.total += weight;
stats.completionCount.completed++;
stats.completionCount.total++;
if (data.textContent.startsWith('100 kills:') || data.textContent.startsWith('20 Guardian') || data.textContent.startsWith('Complete elite robot')) {
document.getElementById("completedcombatContainerInner").appendChild(data);
stats.combatCount.completed++;
stats.combatCount.total++;
stats.categoryCount.completed++;
} else if (data.textContent.startsWith('Mix')) {
document.getElementById("completedbrewingContainerInner").appendChild(data);
stats.brewingCount.completed++;
stats.brewingCount.total++;
stats.categoryCount.completed++;
} else if (data.textContent.startsWith('Prepare')) {
document.getElementById("completedcookingContainerInner").appendChild(data);
stats.cookingCount.completed++;
stats.cookingCount.total++;
stats.categoryCount.completed++;
} else if (data.textContent.endsWith('sent total ')) {
document.getElementById("completedfishingContainerInner").appendChild(data);
stats.fishingCount.completed++;
stats.fishingCount.total++;
stats.categoryCount.completed++;
} else if (data.textContent.startsWith('Max level')) {
document.getElementById("completedskillsContainerInner").appendChild(data);
stats.skillCount.completed++;
stats.skillCount.total++;
stats.categoryCount.completed++;
} else if (data.textContent.startsWith('diamond')) {
document.getElementById("completedtoolsContainerInner").appendChild(data);
stats.toolCount.completed++;
stats.toolCount.total++;
stats.categoryCount.completed++;
} else if (data.textContent.startsWith('Level 20') || data.textContent.endsWith('seeds planted ')) {
document.getElementById("completedfarmingContainerInner").appendChild(data);
stats.farmingCount.completed++;
stats.farmingCount.total++;
stats.categoryCount.completed++;
} else if (data.textContent.endsWith('chopped ')) {
document.getElementById("completedwoodcuttingContainerInner").appendChild(data);
stats.woodcuttingCount.completed++;
stats.woodcuttingCount.total++;
stats.categoryCount.completed++;
} else if (data.textContent.startsWith('Gathering unique')) {
document.getElementById("completedgatheringContainerInner").appendChild(data);
stats.gatheringCount.completed++;
stats.gatheringCount.total++;
stats.categoryCount.completed++;
} else if (data.textContent.startsWith('Find a') || data.textContent.startsWith('All ')) {
document.getElementById("completedmiscContainerInner").appendChild(data);
stats.miscCount.completed++;
stats.miscCount.total++;
stats.categoryCount.completed++;
} else if (data.textContent.startsWith('master ring') || data.textContent.startsWith('All ')) {
document.getElementById("completedinventionContainerInner").appendChild(data);
stats.inventionCount.completed++;
stats.inventionCount.total++;
stats.categoryCount.completed++;
} else if (data.textContent.endsWith('absorbed ') || data.textContent.startsWith('All ')) {
document.getElementById("completedorbContainerInner").appendChild(data);
stats.orbCount.completed++;
stats.orbCount.total++;
stats.categoryCount.completed++;
} else if (data.textContent.startsWith('Craft ') || data.textContent.startsWith('All ')) {
document.getElementById("completedminingContainerInner").appendChild(data);
stats.miningCount.completed++;
stats.miningCount.total++;
stats.categoryCount.completed++;
} else {
document.getElementById("completedUnknownContainerInner").appendChild(data);
}
} else if (data.innerHTML.includes('x.png')) {
data.style.backgroundColor = 'darkred'
data.style.color = 'white'
stats.weight.pending += weight;
stats.weight.total += weight;
stats.completionCount.pending++;
stats.completionCount.total++;
//console.log(data.textContent);
if (data.textContent.startsWith('100 kills:') || data.textContent.startsWith('20 Guardian') || data.textContent.startsWith('Complete elite robot')) {
document.getElementById("pendingcombatContainerInner").appendChild(data);
stats.combatCount.pending++;
stats.combatCount.total++;
stats.categoryCount.pending++;
} else if (data.textContent.startsWith('Mix')) {
document.getElementById("pendingbrewingContainerInner").appendChild(data);
stats.brewingCount.pending++;
stats.brewingCount.total++;
stats.categoryCount.pending++;
} else if (data.textContent.startsWith('Prepare')) {
document.getElementById("pendingcookingContainerInner").appendChild(data);
stats.cookingCount.pending++;
stats.cookingCount.total++;
stats.categoryCount.pending++;
} else if (data.textContent.endsWith('sent total ')) {
document.getElementById("pendingfishingContainerInner").appendChild(data);
stats.fishingCount.pending++;
stats.fishingCount.total++;
stats.categoryCount.pending++;
} else if (data.textContent.startsWith('Max level')) {
document.getElementById("pendingskillsContainerInner").appendChild(data);
stats.skillCount.pending++;
stats.skillCount.total++;
stats.categoryCount.pending++;
} else if (data.textContent.startsWith('diamond')) {
document.getElementById("pendingtoolsContainerInner").appendChild(data);
stats.toolCount.pending++;
stats.toolCount.total++;
stats.categoryCount.pending++;
} else if (data.textContent.startsWith('Level 20') || data.textContent.endsWith('seeds planted ')) {
document.getElementById("pendingfarmingContainerInner").appendChild(data);
stats.farmingCount.pending++;
stats.farmingCount.total++;
stats.categoryCount.pending++;
} else if (data.textContent.endsWith('chopped ')) {
document.getElementById("pendingwoodcuttingContainerInner").appendChild(data);
stats.woodcuttingCount.pending++;
stats.woodcuttingCount.total++;
stats.categoryCount.pending++;
} else if (data.textContent.startsWith('Gathering unique')) {
document.getElementById("pendinggatheringContainerInner").appendChild(data);
stats.gatheringCount.pending++;
stats.gatheringCount.total++;
stats.categoryCount.pending++;
} else if (data.textContent.startsWith('Find a') || data.textContent.startsWith('All ')) {
document.getElementById("pendingmiscContainerInner").appendChild(data);
stats.miscCount.pending++;
stats.miscCount.total++;
stats.categoryCount.pending++;
} else if (data.textContent.startsWith('master ring') || data.textContent.startsWith('All ')) {
document.getElementById("pendinginventionContainerInner").appendChild(data);
stats.inventionCount.pending++;
stats.inventionCount.total++;
stats.categoryCount.pending++;
} else if (data.textContent.endsWith('absorbed ') || data.textContent.startsWith('All ')) {
document.getElementById("pendingorbContainerInner").appendChild(data);
stats.orbCount.pending++;
stats.orbCount.total++;
stats.categoryCount.pending++;
} else if (data.textContent.startsWith('Craft ') || data.textContent.startsWith('All ')) {
document.getElementById("pendingminingContainerInner").appendChild(data);
stats.miningCount.pending++;
stats.miningCount.total++;
stats.categoryCount.pending++;
} else {
document.getElementById("pendingUnknownContainer").appendChild(data);
}
}
});
this.updateCounts();
this.updateVisibility();
this.updateProgress();
}
updateCounts() {
document.getElementById("completedCount").textContent = `(${stats.completionCount.completed} / ${stats.completionCount.total})`;
document.getElementById("completedWeight").textContent = `(${stats.weight.completed} / ${stats.weight.total})`;
document.getElementById("pendingCount").textContent = `(${stats.completionCount.pending} / ${stats.completionCount.total})`;
document.getElementById("pendingWeight").textContent = `(${stats.weight.pending} / ${stats.weight.total})`;
document.getElementById("pendingbrewingDiv-counts").textContent = `(${stats.brewingCount.pending} / ${stats.brewingCount.total})`;
document.getElementById("pendingcombatDiv-counts").textContent = `(${stats.combatCount.pending} / ${stats.combatCount.total})`;
document.getElementById("pendingcookingDiv-counts").textContent = `(${stats.cookingCount.pending} / ${stats.cookingCount.total})`;
document.getElementById("pendingfarmingDiv-counts").textContent = `(${stats.farmingCount.pending} / ${stats.farmingCount.total})`;
document.getElementById("pendingfishingDiv-counts").textContent = `(${stats.fishingCount.pending} / ${stats.fishingCount.total})`;
document.getElementById("pendinggatheringDiv-counts").textContent = `(${stats.gatheringCount.pending} / ${stats.gatheringCount.total})`;
document.getElementById("pendinginventionDiv-counts").textContent = `(${stats.inventionCount.pending} / ${stats.inventionCount.total})`;
document.getElementById("pendingminingDiv-counts").textContent = `(${stats.miningCount.pending} / ${stats.miningCount.total})`;
document.getElementById("pendingmiscDiv-counts").textContent = `(${stats.miscCount.pending} / ${stats.miscCount.total})`;
document.getElementById("pendingorbDiv-counts").textContent = `(${stats.orbCount.pending} / ${stats.orbCount.total})`;
document.getElementById("pendingskillsDiv-counts").textContent = `(${stats.skillCount.pending} / ${stats.skillCount.total})`;
document.getElementById("pendingtoolsDiv-counts").textContent = `(${stats.toolCount.pending} / ${stats.toolCount.total})`;
document.getElementById("pendingwoodcuttingDiv-counts").textContent = `(${stats.woodcuttingCount.pending} / ${stats.woodcuttingCount.total})`;
document.getElementById("completedbrewingDiv-counts").textContent = `(${stats.brewingCount.completed} / ${stats.brewingCount.total})`;
document.getElementById("completedcombatDiv-counts").textContent = `(${stats.combatCount.completed} / ${stats.combatCount.total})`;
document.getElementById("completedcookingDiv-counts").textContent = `(${stats.cookingCount.completed} / ${stats.cookingCount.total})`;
document.getElementById("completedfarmingDiv-counts").textContent = `(${stats.farmingCount.completed} / ${stats.farmingCount.total})`;
document.getElementById("completedfishingDiv-counts").textContent = `(${stats.fishingCount.completed} / ${stats.fishingCount.total})`;
document.getElementById("completedgatheringDiv-counts").textContent = `(${stats.gatheringCount.completed} / ${stats.gatheringCount.total})`;
document.getElementById("completedinventionDiv-counts").textContent = `(${stats.inventionCount.completed} / ${stats.inventionCount.total})`;
document.getElementById("completedminingDiv-counts").textContent = `(${stats.miningCount.completed} / ${stats.miningCount.total})`;
document.getElementById("completedmiscDiv-counts").textContent = `(${stats.miscCount.completed} / ${stats.miscCount.total})`;
document.getElementById("completedorbDiv-counts").textContent = `(${stats.orbCount.completed} / ${stats.orbCount.total})`;
document.getElementById("completedskillsDiv-counts").textContent = `(${stats.skillCount.completed} / ${stats.skillCount.total})`;
document.getElementById("completedtoolsDiv-counts").textContent = `(${stats.toolCount.completed} / ${stats.toolCount.total})`;
document.getElementById("completedwoodcuttingDiv-counts").textContent = `(${stats.woodcuttingCount.completed} / ${stats.woodcuttingCount.total})`;
}
updateVisibility() {
if(stats.categoryCount.pending = stats.completionCount.pending) {
document.getElementById("pendingunknownContainer").style.display = 'none';
} else {
document.getElementById("pendingunknownContainer").style.display = '';
};
if(stats.categoryCount.completed = stats.completionCount.pending) {
document.getElementById("completedunknownContainer").style.display = 'none';
} else {
document.getElementById("completedunknownContainer").style.display = '';
};
// Brewing
if(stats.brewingCount.pending == 0) {
document.getElementById("pendingbrewingContainer").style.display = 'none';
} else {
document.getElementById("pendingbrewingContainer").style.display = '';
};
if(stats.brewingCount.completed == 0) {
document.getElementById("completedbrewingContainer").style.display = 'none';
} else {
document.getElementById("completedbrewingContainer").style.display = '';
};
// Combat
if(stats.combatCount.pending == 0) {
document.getElementById("pendingcombatContainer").style.display = 'none';
} else {
document.getElementById("pendingcombatContainer").style.display = '';
};
if(stats.combatCount.completed == 0) {
document.getElementById("completedcombatContainer").style.display = 'none';
} else {
document.getElementById("completedcombatContainer").style.display = '';
};
// Cooking
if(stats.cookingCount.pending == 0) {
document.getElementById("pendingcookingContainer").style.display = 'none';
} else {
document.getElementById("pendingcookingContainer").style.display = '';
};
if(stats.cookingCount.completed == 0) {
document.getElementById("completedcookingContainer").style.display = 'none';
} else {
document.getElementById("completedcookingContainer").style.display = '';
};
// Farming
if(stats.farmingCount.pending == 0) {
document.getElementById("pendingfarmingContainer").style.display = 'none';
} else {
document.getElementById("pendingfarmingContainer").style.display = '';
};
if(stats.farmingCount.completed == 0) {
document.getElementById("completedfarmingContainer").style.display = 'none';
} else {
document.getElementById("completedfarmingContainer").style.display = '';
};
// Fishing
if(stats.fishingCount.pending == 0) {
document.getElementById("pendingfishingContainer").style.display = 'none';
} else {
document.getElementById("pendingfishingContainer").style.display = '';
};
if(stats.fishingCount.completed == 0) {
document.getElementById("completedfishingContainer").style.display = 'none';
} else {
document.getElementById("completedfishingContainer").style.display = '';
};
// Gathering
if(stats.gatheringCount.pending == 0) {
document.getElementById("pendinggatheringContainer").style.display = 'none';
} else {
document.getElementById("pendinggatheringContainer").style.display = '';
};
if(stats.gatheringCount.completed == 0) {
document.getElementById("completedgatheringContainer").style.display = 'none';
} else {
document.getElementById("completedgatheringContainer").style.display = '';
};
// Invention
if(stats.inventionCount.pending == 0) {
document.getElementById("pendinginventionContainer").style.display = 'none';
} else {
document.getElementById("pendinginventionContainer").style.display = '';
};
if(stats.inventionCount.completed == 0) {
document.getElementById("completedinventionContainer").style.display = 'none';
} else {
document.getElementById("completedinventionContainer").style.display = '';
};
// Mining
if(stats.miningCount.pending == 0) {
document.getElementById("pendingminingContainer").style.display = 'none';
} else {
document.getElementById("pendingminingContainer").style.display = '';
};
if(stats.miningCount.completed == 0) {
document.getElementById("completedminingContainer").style.display = 'none';
} else {
document.getElementById("completedminingContainer").style.display = '';
};
// Misc
if(stats.miscCount.pending == 0) {
document.getElementById("pendingmiscContainer").style.display = 'none';
} else {
document.getElementById("pendingmiscContainer").style.display = '';
};
if(stats.miscCount.completed == 0) {
document.getElementById("completedmiscContainer").style.display = 'none';
} else {
document.getElementById("completedmiscContainer").style.display = '';
};
// Orb
if(stats.orbCount.pending == 0) {
document.getElementById("pendingorbContainer").style.display = 'none';
} else {
document.getElementById("pendingorbContainer").style.display = '';
};
if(stats.orbCount.completed == 0) {
document.getElementById("completedorbContainer").style.display = 'none';
} else {
document.getElementById("completedorbContainer").style.display = '';
};
// Skill
if(stats.skillCount.pending == 0) {
document.getElementById("pendingskillsContainer").style.display = 'none';
} else {
document.getElementById("pendingskillsContainer").style.display = '';
};
if(stats.skillCount.completed == 0) {
document.getElementById("completedskillsContainer").style.display = 'none';
} else {
document.getElementById("completedskillsContainer").style.display = '';
};
// Tool
if(stats.toolCount.pending == 0) {
document.getElementById("pendingtoolsContainer").style.display = 'none';
} else {
document.getElementById("pendingtoolsContainer").style.display = '';
};
if(stats.toolCount.completed == 0) {
document.getElementById("completedtoolsContainer").style.display = 'none';
} else {
document.getElementById("completedtoolsContainer").style.display = '';
};
// Woodcutting
if(stats.woodcuttingCount.pending == 0) {
document.getElementById("pendingwoodcuttingContainer").style.display = 'none';
} else {
document.getElementById("pendingwoodcuttingContainer").style.display = '';
};
if(stats.woodcuttingCount.completed == 0) {
document.getElementById("completedwoodcuttingContainer").style.display = 'none';
} else {
document.getElementById("completedwoodcuttingContainer").style.display = '';
};
}
calculateFinalCookTime(itemName, itemTotal) {
const chefHat = IdlePixelPlus.getVarOrDefault("chefs_hat", 0, "int");
if (itemTotal >= 25) return 0;
if (chefHat == 0) {
let tempCooktime = (25 - itemTotal) * cookTimes[itemName];
return tempCooktime;
};
const baseCookTime = cookTimes[itemName];
if (itemTotal >= 10) {
return Math.ceil((25 - itemTotal) / 2) * baseCookTime / 2;
} else if (itemTotal >= 5) {
return ((5 - itemTotal) * baseCookTime / 2) + (baseCookTime / 2 * 8);
} else {
return ((5 - itemTotal) * baseCookTime) + (baseCookTime / 2 * 13);
}
}
updateOrCreateColumnWithCookTimes() {
var table = document.getElementById("cooks_book-table");
var rows = table.getElementsByTagName("tr");
// Determine whether the "TIME FOR COMPLETIONIST" column already exists
var headerExists = document.getElementById("cookCompletion");
var columnIndex;
// If the header does not exist, add it and determine its index
if (!headerExists) {
let headerRow = rows[0];
let newHeaderCell = headerRow.insertCell(-1); // Append the new header cell at the end
newHeaderCell.id = "cookCompletion";
newHeaderCell.width = "10%";
newHeaderCell.className = "p-2";
newHeaderCell.setAttribute("original-width", "10%");
newHeaderCell.textContent = "TIME FOR COMPLETIONIST";
columnIndex = headerRow.cells.length - 1; // Get the index of the new column
} else {
columnIndex = headerExists.cellIndex; // Get the index from the existing header
}
// Update or create cells in the existing or new column
for (var i = 1; i < rows.length; i++) {
var itemName = rows[i].getAttribute('data-cooks_book-item');
var itemTotal = IdlePixelPlus.getVarOrDefault(itemName + "_prepared_total", 0, "int");
var cellToUpdate;
// Check if the cell already exists in this row at the columnIndex
if (rows[i].cells.length > columnIndex) {
cellToUpdate = rows[i].cells[columnIndex];
} else {
// If the cell does not exist, add it
cellToUpdate = rows[i].insertCell(columnIndex);
}
if (cookTimes.hasOwnProperty(itemName)) {
var finalCookTime = this.calculateFinalCookTime(itemName, itemTotal);
cellToUpdate.innerHTML = finalCookTime;
cellToUpdate.className = "p-2 color-grey font-small";
cellToUpdate.style.color = "rgb(255, 0, 0)";
} else {
cellToUpdate.innerHTML = "N/A";
}
}
}
onLogin() {
//Insert Code Here
};
onVariableSet(key, valueBefore, valueAfter) {
//Insert Code Here
};
onConfigChange() {
//Insert Code Here
};
onPanelChanged(panelBefore, panelAfter) {
if(panelAfter == "completionist") {
this.updateCompletetionist();
}
if(panelAfter == "cooking") {
this.updateOrCreateColumnWithCookTimes();
}
}
}
const plugin = new UITweaksPlugin();
IdlePixelPlus.registerPlugin(plugin);
})();