// ==UserScript== // @name MH - Consolidated Map Colour Coder // @description Colour code your maps // @author Chromatical // @version 1.2.10 // @match https://www.mousehuntgame.com/* // @match https://apps.facebook.com/mousehunt/* // @icon https://www.google.com/s2/favicons?domain=mousehuntgame.com // @grant none // @namespace https://greasyfork.org/users/748165 // @downloadURL https://update.greasyfork.icu/scripts/428959/MH%20-%20Consolidated%20Map%20Colour%20Coder.user.js // @updateURL https://update.greasyfork.icu/scripts/428959/MH%20-%20Consolidated%20Map%20Colour%20Coder.meta.js // ==/UserScript== //Which style to apply var applyThisStyle; $(document).ajaxComplete(async(event,xhr,options) => { if (options.url == "https://www.mousehuntgame.com/managers/ajax/board/board.php"){ $("#chro-madcoder-settings-button")[0] ? null : addButtons(); process(); //Event listener to change map var allMap = $(".treasureMapRootView-tab"); for (var i=0;i el.remove()); //Highlight uncaught only? const isChecked = localStorage.getItem("highlightPref") === "uncaught-only" ? true : false; //Where to insert var insertDiv = $(".treasureMapView-leftBlock .treasureMapView-block-content")[0] //Highlight Div const masterDiv = insertDiv.insertAdjacentElement("afterbegin", createElement("div",{ attrs:{ id: "mapcoder-master-div" }, css:{ "display": "inline-flex", "margin-bottom": "10px", "width": "100%", "text-align": "center", "line-height": "1.5", "overflow": "hidden" } })); //All the mice are listed here var allList = $(".treasureMapView-goals-group-goal") //Reset to white background for (var a=0;a{ var groupName = el[0] var colour = el[1] var miceGroupList = []; el[2].forEach(mice =>{ miceGroupList.push(mice) }) var count = 0; for (var i=0;i-1){ count++ allList[i].style.backgroundColor = colour; break; } if (caughtList.indexOf(allList[i].innerText)>-1){ isChecked == true? null: allList[i].style.backgroundColor = colour break; } } } } const smallDiv = createElement("div",{ props: { class: "mapcoder-highlight-group-div", innerText: groupName + "\n" + count }, css: { "width": "auto", "padding": "5px", "font-weight": "bold", "font-size": "12.5px", backgroundColor: clr(colour) } }) function clr(colour){ var clr; count > 0? clr = colour: clr = "grey"; return clr }; masterDiv.appendChild(smallDiv); }) //Check if you actually have that style if(map[1][1]){ if ($(".treasureMapView-goals-groups")[1]){ if ($(".treasureMapView-goals-groups")[1].innerText.includes("Missing")){ filter($(".treasureMapView-goals-groups")[0].children[1]); filter($(".treasureMapView-goals-groups")[1].children[1]); } else { filter($(".treasureMapView-goals-groups")[0].children[1]); } }; function filter(oriUnfiltered){ var countA = oriUnfiltered.getElementsByTagName("a"); var unfiltered = document.createElement("div") while (countA.length > 0){ var clone = countA[0].cloneNode(true); unfiltered.appendChild(clone); oriUnfiltered.removeChild(countA[0]) } var countB = unfiltered.getElementsByTagName("a").length; for (var q =0; q el.remove()) const mainDiv = document.body.appendChild(createElement("div",{ attrs: { id: "chro-mapcode-settings-div", }, css: { backgroundColor : "#F5F5F5", position: "fixed", zIndex: "9999", left: "35vw", top: "20vh", border: "solid 2px #696969", borderRadius: "20px", padding: "10px", textAlign: "center", fontSize: "12px", }, children: [buttonDiv(),content()] })) function buttonDiv(){ const buttonDiv = createElement("div",{ attrs: { id: "chro-mapcoder-settings-header-div" }, children:[ createElement("div",{ props:{ innerText: "Settings" }, css:{ float: "left", paddingTop: "4px", marginLeft: "52px", fontWeight: "bold" } }), createElement("button",{ attrs:{ id: "mapcoder-close-button" }, props:{ innerText: "x" }, css:{ float: "right" }, action:{ click(){close(buttonDiv)} } })] }) function close(div){ document.body.removeChild($("#chro-mapcode-settings-div")[0]) }; return buttonDiv } function content(){ const content = createElement("div",{ attrs:{ id: "chro-mapcode-content-div" }, css: { paddingTop: "25px", width: "175px" }, children:[checkHighlight(),addManualStyle(),removeManualStyle(),loadPresetStyle()] }) return content } //Highlight --- uncaught mice or all-------------- function checkHighlight(){ var isChecked = localStorage.getItem("highlightPref") == "uncaught-only" ? true : false; var isCheckedStr = isChecked ? "checked" : ""; const highlight = createElement("tr",{ children:[ createElement("label",{ attrs:{ for: "chro-mapcoder-highlight-box" }, props:{ innerText: "Highlight uncaught mice only" } }), createElement("input",{ attrs:{ type: "checkbox", id: "chro-check-box", name: "chro-mopcoder-highlight-box", }, action:{ click(){changeCheck()} }, props:{ checked:isChecked } })] }) function changeCheck(){ var check = $("#chro-check-box")[0]; if (check.checked == true){ localStorage.setItem("highlightPref","uncaught-only"); isCheckedStr = "checked" } else { localStorage.setItem("highlightPref","all"); isCheckedStr = "" } colourise(); }; return highlight } //Check highlight end-------------------------------- //Add manual style begins----------------------------------------------------------------------- function addManualStyle(){ const manualButton = createElement("button",{ attrs:{ id:"chro-mapcode-manual-style-button" }, props: { innerText: "Add Mice Group" }, css: { marginTop: "5px" }, action:{ click(){addManual()} } }) function addManual(){ document .querySelectorAll("#chro-mapcode-pickstyle-div") .forEach(el=> el.remove()) const mainDiv = document.body.appendChild(createElement("div",{ attrs: { id: "chro-mapcode-pickstyle-div", }, css: { backgroundColor : "#F5F5F5", position: "fixed", zIndex: "9999", left: "35vw", top: "20vh", border: "solid 2px #696969", borderRadius: "20px", padding: "10px", textAlign: "center", fontSize: "12px", }, children: [manualBox()] })) function manualBox(){ const manualBox = createElement("div",{ children: [table(),selected(),buttons()] }) function table(){ const table = createElement("table",{ css: { borderSpacing: "1em 2px" }, children:[ createElement("tr",{ children:[ createElement("td",{ children:[ createElement("label",{ attrs:{ id: "chro-mapcoder-manual-label", for: "chro-mapcoder-manual-input" }, props:{ innerText: "Group Name:" } })] }), createElement("td",{ children:[ createElement("input",{ attrs:{ id: "chro-mapcoder-manual-input", type: "text", size: "10" } })] })] }), createElement("tr",{ children:[ createElement("td",{ children:[ createElement("label",{ attrs:{ id: "chro-mapcoder-manual-colour-label", for: "chro-mapcoder-manual-colour-input" }, props:{ innerText: "Colour:" } })] }), createElement("td",{ children: [ createElement("input",{ attrs:{ id:"chro-mapcoder-manual-colour-input", type: "text", size: "10" } })] })] })] }) return table } function selected(){ const selected = createElement("div",{ attrs:{ id: "chro-mapcoder-selected-mice" }, props:{ innerText: "Selected Mice:" } }) return selected } function buttons(){ const buttons = createElement("div",{ children:[ createElement("button",{ attrs:{ id:"chro-mapcoder-manual-confirm-btn" }, props:{ innerText: "Confirm" }, action:{ click(){add()} } }), createElement("button",{ attrs:{ id: "chro-mapcoder-manual-cancel-btn" }, props:{ innerText: "Cancel" }, action:{ click(){close()} } })] }) //Close function function close(){ document.body.removeChild($("#chro-mapcode-pickstyle-div")[0]); for (var i=0; i 0 && parsedData){ for (var j=0;j el.remove()) //colourise it again applyThisStyle = map; colourise(); } } return buttons } return manualBox } var allSpans = $(".treasureMapView-goals-group-goal") var current = []; for (var i=0; i =0){ this.style.backgroundColor = "white"; this.style.fontWeight = ""; var x = current.indexOf(mouseName); current.splice(x,1); if (target.children.length !== 0){ const {children} = target; for (var j=0; j")[0] console.log(groupName); //Gettings styles from localStorage const data = localStorage.getItem("Chro-mapcoder-styles") if (data){var parsedData = JSON.parse(data)} for (var j=0;j el.remove()); //ReColour applyThisStyle = map colourise(); } } return masterDiv } return removeManualButton } //Remove button ends ---------------------------------------------------------------------- //Load preset button begins---------------------- function loadPresetStyle(){ const presetButton = createElement("button",{ attrs:{ id:"chro-mapcode-preset-button" }, props: { innerText: "Reset All Presets" }, css: { marginTop: "5px" }, action:{ click(){loadPreset()} } }) return presetButton } dragElement(mainDiv,mainDiv); } function loadPreset(){ alert("Preset styles loaded, reload map to load styles"); localStorage.setItem("Chro-mapcoder-styles",JSON.stringify([ //Follow this style ["Queso Canyon Grand Tour Treasure Chest",[ ["KSS","#6699CC",["Kalor'ignis of the Geyser","Stormsurge, the Vile Tempest"]], //blue ["CinBrut","#99ff66",["Bruticus, the Blazing","Cinderstorm"]], //green ["BE 3","#ff6666",["Ignatia","Smoldersnap","Bearded Elder"]], //red ["SizM","yellow",["Sizzle Pup","Mild Spicekin"]], ["Pressure","#cc99ff",["Pyrehyde","Steam Sailor","Vaporior","Warming Wyvern"]], //purple ["QR", "#00cc44",["Pump Raider","Tiny Saboteur","Croquet Crusher","Sleepy Merchant"]], //darker green ["Corky", "orange",["Fuzzy Drake","Rambunctious Rain Rumbler","Horned Cork Hoarder","Cork Defender","Burly Bruiser","Corky, the Collector"]], ["PP", "#99ffff",["Old Spice Collector","Spice Farmer","Spice Sovereign","Spice Raider","Granny Spice","Spice Finder","Spice Seer","Spice Reaper"]], //cyan ["CQ", "pink",["Rubble Rouser","Rubble Rummager","Tiny Toppler","Ore Chipper","Chip Chiseler","Grampa Golem","Nachore Golem","Fiery Crusher",]], ["Boss", "silver",["Inferna, The Engulfed","Nachous, The Molten","Queen Quesada","Emberstone Scaled","Corkataur",]] ]], ["Sky Pirate Treasure Chest",[ ["LP","#c97c49",["Skydiver","Skygreaser","Launchpad Labourer","Cloud Miner"]], ["Ward","#ffffff",["Warden of Rain","Warden of Wind","Warden of Frost","Warden of Fog"]], ["Phys","#59e031",["Ground Gavaleer","Sky Swordsman","Herc","Sky Squire","Paragon of Strength"]], ["Shadow","#8f75e2",["Paragon of Shadow","Astrological Astronomer","Overcaster","Stratocaster","Shadow Sage"]], ["Tact","#fff935",["Paragon of Tactics","Worried Wayfinder","Gyrologer","Seasoned Islandographer","Captain Cloudkicker"]], ["Arc","#0be496",["Paragon of Arcane","Sky Glass Sorcerer","Sky Glass Glazier","Sky Dancer","Sky Highborne"]], ["Forg","#338838",["Paragon of Forgotten","Spry Sky Explorer","Spry Sky Seer","Cumulost","Spheric Diviner"]], ["Hydro","#5d9fce",["Paragon of Water","Nimbomancer","Sky Surfer","Cute Cloud Conjurer","Mist Maker"]], ["Draco","#f06a60",["Paragon of Dragons","Tiny Dragonfly","Lancer Guard","Dragonbreather","Regal Spearman"]], ["Law","#f9a645",["Paragon of the Lawless","Devious Gentleman","Stack of Thieves","Lawbender","Agent M"]], ["Pirate","#ECA4A6",["Suave Pirate","Cutthroat Pirate","Cutthroat Cannoneer","Scarlet Revenger","Mairitime Pirate"]] ]], ["Empyrean Sky Palace Treasure Chest",[ ["LP","#c97c49",["Skydiver","Skygreaser","Launchpad Labourer","Cloud Miner"]], ["Ward","#ffffff",["Warden of Rain","Warden of Wind","Warden of Frost","Warden of Fog"]], ["Phys","#59e031",["Ground Gavaleer","Sky Swordsman","Herc","Sky Squire","Paragon of Strength","Glamorous Gladiator"]], ["Shad","#8f75e2",["Paragon of Shadow","Astrological Astronomer","Overcaster","Stratocaster","Shadow Sage","Zealous Academic"]], ["Tact","#fff935",["Paragon of Tactics","Worried Wayfinder","Gyrologer","Seasoned Islandographer","Captain Cloudkicker","Rocketeer"]], ["Arc","#0be496",["Paragon of Arcane","Sky Glass Sorcerer","Sky Glass Glazier","Sky Dancer","Sky Highborne","Sky Glider"]], ["Forg","#338838",["Paragon of Forgotten","Spry Sky Explorer","Spry Sky Seer","Cumulost","Spheric Diviner","Forgotten Elder"]], ["Hyd","#5d9fce",["Paragon of Water","Nimbomancer","Sky Surfer","Cute Cloud Conjurer","Mist Maker","Cloud Strider"]], ["Drac","#f06a60",["Paragon of Dragons","Tiny Dragonfly","Lancer Guard","Dragonbreather","Regal Spearman","Empyrean Javelineer"]], ["Law","#f9a645",["Paragon of the Lawless","Devious Gentleman","Stack of Thieves","Lawbender","Agent M","Aristo-Cat Burglar"]], ["Pir","#ECA4A6",["Suave Pirate","Cutthroat Pirate","Cutthroat Cannoneer","Scarlet Revenger","Mairitime Pirate", "Admiral Cloudbeard"]], ["Rich","#E3E024",["Richard the Rich"]], ["SP","#7DDBDA",["Fortuitous Fool","Empyrean Appraiser","Empyrean Geologist","Consumed Charm Tinkerer","Empyrean Empress", "Peggy the Plunderer"]] ]], ["Halloween Treat Treasure Chest",[ ["Standard","#fff935",["Grey Recluse","Cobweb","Teenage Vampire","Zombot Unipire","Candy Cat","Candy Goblin","Shortcut","Tricky Witch","Sugar Rush"]], ["Jack O","#f9a645",["Spirit Light","Gourdborg","Pumpkin Hoarder","Trick","Treat","Wild Chainsaw","Maize Harvester"]] ]], ["Halloween Trick Treasure Chest",[ ["Bone","#bfbfbf",["Creepy Marionette","Dire Lycan","Grave Robber","Hollowhead","Mousataur Priestess","Sandmouse","Titanic Brain-Taker","Tomb Exhumer"]], ["Polter","#5d9fce",["Admiral Arrrgh","Captain Cannonball","Ghost Pirate Queen","Gourd Ghoul","Scorned Pirate","Spectral Butler","Spectral Swashbuckler"]], ["Scream","#5ae031",["Baba Gaga","Bonbon Gummy Globlin","Hollowed","Hollowed Minion","Swamp Thang"]] ]], ["Nice Treasure Chest",[ ["Std","#fff935",["Hoarder","Gingerbread"]], ["SB","#f7f6f6",["Mouse of Winter Past","Mouse of Winter Present","Mouse of Winter Future","Scrooge"]], ["PP","#ba6900",["Builder","Snow Golem Jockey","Nice Knitting","Glacia Ice Fist","Borean Commander","Frigid Foreman","Great Winter Hunt Impostor","Naughty Nougat","Snow Golem Jockey","Snow Scavenger","Ridiculous Sweater","Stuck Snowball","Iceberg Sculptor","Shorts-All-Year","Great Giftnapper"]], ["Winter","#dedede",["Snowflake"]], ["LISC","#4882d1",["Snow Golem Architect"]] ]], ["Naughty Treasure Chest",[ ["PP","#c97c49",["Builder","Snow Golem Jockey","Nice Knitting","Glacia Ice Fist","Borean Commander","Frigid Foreman","Great Winter Hunt Impostor","Naughty Nougat","Snow Golem Jockey","Snow Scavenger","Ridiculous Sweater","Stuck Snowball","Iceberg Sculptor","Shorts-All-Year","Great Giftnapper"]], ["Sports","#df74f7",["Sporty Ski Instructor","Young Prodigy Racer","Toboggan Technician","Free Skiing","Nitro Racer","Rainbow Racer","Double Black Diamond Racer","Black Diamond Racer"]], ["Toys","#f06a60",["Nutcracker","Toy","Slay Ride","Squeaker Claws","Destructoy","Toy Tinkerer","Mad Elf","Elf"]], ["Orna","#5ae031",["Christmas Tree","Stocking","Candy Cane","Ornament","Missile Toe","Wreath Thief","Ribbon","Snowglobe"]], ["Snow","#4fcaff",["Snow Fort","Snowball Hoarder","S.N.O.W. Golem","Snow Sorceress","Reinbo","Tundra Huntress","Snowblower","Snow Boulder"]], ["Firewks","#cd87ff",["Frightened Flying Fireworks","New Year's","Party Head"]], ["Glazy","#fcaf35",["Glazy","Joy"]], ["LISC","#4882d1",["Snow Golem Architect"]], ["Boss","#999999",["Ol' King Coal"]] ]], ["Birthday Treasure Chest",[ ["Std","#ab846a",["Birthday","Buckethead","Present","Pintail","Dinosuit","Sleepwalker","Terrible Twos"]], ["SB","#e8e4e7",["Cheesy Party"]], ["Mixing","#1ec7b6",["Force Fighter Blue","Force Fighter Green","Force Fighter Pink","Force Fighter Red","Force Fighter Yellow","Super FighterBot MegaSupreme"]], ["Break","#e98eb5",["Breakdancer","Fete Fromager","Dance Party","El Flamenco","Para Para Dancer"]], ["Pump","#e3ac30",["Reality Restitch","Time Punk","Time Tailor","Time Thief","Space Party-Time Plumber"]], ["QA","#6c71c6",["Cupcake Candle Thief","Cupcake Cutie","Sprinkly Sweet Cupcake Cook","Cupcake Camo","Cupcake Runner"]], ["FRC","#a9edf9",["Factory Technician"]], ["Vince","#cd87ff",["Vincent, The Magnificent"]], ]] ["Fort Rox Treasure Chest",[ ["Day","yellow",["Meteorite Snacker","Mining Materials Manager","Mischievous Meteorite Miner","Hardworking Hauler","Meteorite Miner","Meteorite Mover"]], ["Dawn","silver",["Dawn Guardian","Monster of the Meteor"]], ["Special","pink",["Nightmancer","Nightfire"]], ["Shadow","orange",["Night Shift Materials Manager","Werehauler","Wealthy Werewarrior","Mischievous Wereminer","Alpha Weremouse","Wereminer","Reveling Lycanthrope"]], ["Arcane","#6699CC",["Hypnotized Gunslinger","Arcane Summoner","Night Watcher","Cursed Taskmaster","Meteorite Golem","Meteorite Mystic"]] //blue ]], ])) } function createElement(tagName, config = {}){ const el = document.createElement(tagName); if (config.attrs) Object.entries(config.attrs).forEach(([attr, val]) => el.setAttribute(attr, val)); if (config.props) Object.entries(config.props).forEach(([prop, val]) => el[prop] = val); if (config.css) Object.entries(config.css).forEach(([prop, val]) => el.style[prop] = val); if (config.children) config.children.forEach(child => el.append(child)); if (config.action) Object.entries(config.action).forEach(([prop,val]) => el.addEventListener(prop,()=>{val()})); return el; }; function dragElement(elmnt,dragEl) { var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0; /*if (elmnt.firstElementChild) { // if present, the header is where you move the DIV from: elmnt.firstElementChild.onmousedown = dragMouseDown; } else {*/ // otherwise, move the DIV from anywhere inside the DIV: dragEl.onmousedown = dragMouseDown; //} function dragMouseDown(e) { e = e || window.event; e.preventDefault(); // get the mouse cursor position at startup: pos3 = e.clientX; pos4 = e.clientY; document.onmouseup = closeDragElement; // call a function whenever the cursor moves: document.onmousemove = elementDrag; } function elementDrag(e) { e = e || window.event; e.preventDefault(); // calculate the new cursor position: pos1 = pos3 - e.clientX; pos2 = pos4 - e.clientY; pos3 = e.clientX; pos4 = e.clientY; // set the element's new position: elmnt.style.top = (elmnt.offsetTop - pos2) + "px"; elmnt.style.left = (elmnt.offsetLeft - pos1) + "px"; } function closeDragElement() { // stop moving when mouse button is released: document.onmouseup = null; document.onmousemove = null; } }