I am trying to check the table entry for a webscrape for the ‘color’ element in the innerhtml and then change the variable for “bonus” based on which of the table entries have this value.
I can post the innerHTML version and see it there but I can’t not seem to get the script to recognize it is there.
let checkCrimes = {
"check": function() {
if (user.stamina < 690) {
let randomTimer = Math.floor(Math.random() * 300 + 900);
checkCrimes.queue(randomTimer);
} else if ($(gameDocument).find('#crimebubble').length) {
let crimeCooldown = $(gameDocument).find("#crimebubble>.countdown").eq(0).text().split(":");
crimeCooldown = crimeCooldown.map((x, i) => {
if (i === 0) {
return Number(x) * 60;
} else {
return Number(x);
}
});
crimeCooldown = crimeCooldown.reduce((a, b) => a + b);
checkCrimes.queue(crimeCooldown);
} else if ($(gameDocument).find('#form_crimes').length) {
let lastPostTime = localStorage.getItem('lastPostTime') || 0;
if ($(gameDocument).find('#form_crimes input[type="radio"]').length > 10) {
// Handle other cases or skip if necessary
} else {
let crimeList = [];
$(gameDocument).find('#form_crimes tbody tr').each(function() {
const crimeData = $(this).find('td').toArray().map(x => x.innerHTML);
if (crimeData.includes('--')) {
return; // Exclude entries with "--" from the list
}
const bonus = "testfailed";
if (crime.Data[3].includes('color')) {
bonus = "Stealth"
}
if (crime.Data[2].includes('color')) {
bonus = "Defense"
}
if (crime.Data[1].includes('color')) {
bonus = "Offense"
}
const trimmedCrimeData = [crimeData[1], crimeData[2], crimeData[3], crimeData[6], bonus];
crimeList.push(trimmedCrimeData);
});
I have also tried just checking the entire crimeData array for the entry just to check and it didn’t work either. But this is effectively what I want to do in this function: scrape the crime table, check which one has the bonus, push text only to the trimedCrimeData
here is the HTML I am working with if it helps
18%, 50%, <span style="color:#00B910;font-size:11px;">37%</span>, <span class="wartooltip" style="margin:0px;"><span style="color:lime;">strong</span><span class="wartooltiptext">Strength indicated how strong the crime is, strong is good and weak is bad!</span></span>, off
66%, 9%, <span style="color:#00B910;font-size:11px;">30%</span>, <span class="wartooltip" style="margin:0px;"><span style="color:grey;">normal</span><span class="wartooltiptext">Strength indicated how strong the crime is, strong is good and weak is bad!</span></span>, off
10%, 44%, <span style="color:#00B910;font-size:11px;">51%</span>, <span class="wartooltip" style="margin:0px;"><span style="color:lime;">strong</span><span class="wartooltiptext">Strength indicated how strong the crime is, strong is good and weak is bad!</span></span>, off