Last active
July 14, 2023 01:37
-
-
Save Infinitay/56c58da8af1e5d6afc23fd174439ea2f to your computer and use it in GitHub Desktop.
osrs db (chisel) - Gets all trees and it's name, id, and actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://chisel.weirdgloop.org/moid/object_name.html#/(.*)?tree$/ | |
let map = new Map(); | |
// Get all the rows from the table | |
let table = document.getElementById("table"); | |
let rows = table.getElementsByTagName("tr"); | |
// Specify the desired actions | |
let desiredActions = ["Chop", "Chop down", "Chop-down", "Cut", "Cut down", "Cut-down"]; | |
// Iterate through each row | |
for (let i = 0; i < rows.length; i++) { | |
let row = rows[i]; | |
let id = row.id; | |
let nameCell = row.querySelector(".name"); | |
let actionsCell = row.querySelector(".actions"); | |
// Check if the actions column contains only the desired values | |
if (actionsCell && !!actionsCell.innerHTML) { | |
let actionsArray = JSON.parse(actionsCell.innerHTML); | |
if (actionsArray.length === 1 && desiredActions.includes(actionsArray[0])) { | |
// Access the specific columns | |
// console.log(`${nameCell.innerHTML} [${id}] with actions: ${actionsArray.join(", ")}`); | |
if (!map.has(nameCell.innerHTML)) { | |
map.set(nameCell.innerHTML, new Set()); | |
} | |
map.get(nameCell.innerHTML).add(parseInt(id)); | |
} | |
} | |
} | |
// map.forEach(function(ids, name) { | |
// console.log(`"${name}": [${Array.from(ids).join(", ")}]`); | |
// }); | |
map.forEach(function(ids, name) { | |
var idList = Array.from(ids).map(id => `${name.replaceAll(" ", "_").toUpperCase()}_${id}`); | |
console.log(idList.join(", ")); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment