Skip to content

Instantly share code, notes, and snippets.

@knuxify
Last active September 3, 2024 06:27
Show Gist options
  • Select an option

  • Save knuxify/64a79f02ad2da6501a8d755dcf5c28ff to your computer and use it in GitHub Desktop.

Select an option

Save knuxify/64a79f02ad2da6501a8d755dcf5c28ff to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name BotB: MessageBlock
// @namespace https://battleofthebits.com/barracks/Profile/uart/
// @version 2024-08-30
// @description MSGs may not appear at random. =P
// @author uart @ botb
// @match *://battleofthebits.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=battleofthebits.com
// @grant none
// @run-at document-body
// ==/UserScript==
(function() {
'use strict';
console.log("messageblock loaded");
const messagesToBlock = [
"MSGs may appear at random. =P",
"<img src=\"/disk/npc/boon_bandit.gif\">\"Y'know some botbrs ain't logged in over a year? Easy pickings'! Whaddabuncha n0000bs!!!\"",
"<img src=\"/disk/npc/taxman.gif\"> The taxman brings a prediction! <br> \"Yikes, the Omnibus Bank of BotB is in the red! Everyone will be paying 20% next May!\"",
"<img src=\"/disk/npc/selganor.gif\">\"I would show you a trick but the taxman stole my cards. What an uncivilized society!\"",
"<img src=\"/disk/npc/merchant1.gif\"> A merchant approaches you! o__O<br> \"Yaargh, wish I had wares to sell ya!\"",
"<img src=\"/disk/npc/merchant2.gif\"> A merchant crosses your path -<br> \"I've got nothing, I tell ya.\"",
"<img src=\"/disk/npc/monkey.gif\"> Beware monkey licks! ",
"<img src=\"/disk/npc/ducky.gif\"> Quack! Quack!!",
"<img src=\"/disk/npc/taxman.gif\"> A taxman suddenly appears! x__X<br> \"Hey, don't look at me. I just work here!\"",
"<img src=\"/disk/npc/double_pony.gif\"> Teh double headed pony! =D/ ",
"<img src=\"/disk/npc/beer.gif\"> Relax, have a drink. ;D",
"<img src=\"/disk/npc/gnome.gif\"> <img src=\"/disk/npc/gnome.gif\"> The gnomes are coming!! :o",
"<img src=\"/disk/npc/zombie.gif\"> <img src=\"/disk/npc/ghoul.gif\"> Beware teh baddies! =o",
];
// make sure we don't trigger on the player which has no pageBG element
if (document.getElementById("pageBG")) {
// #pageBG > div.grid_1 > div.grid_10 > div.uiWindow
var messagebox = document.getElementById("pageBG").getElementsByClassName("grid_1")[0].getElementsByClassName("grid_10")[0].getElementsByClassName("uiWindow")[0];
/* each message is a separate <p> element; the last element in the box is an <a> element which is the close button */
if (messagebox) {
for (var i = 0; i < (messagebox.childElementCount - 1); i++) {
const messageHTML = messagebox.children[i];
if (messagesToBlock.includes(messageHTML.innerHTML)) {
messageHTML.remove();
i--;
}
}
if (messagebox.childElementCount <= 1) {
messagebox.remove();
}
} else {
console.log("no messagebox");
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment