Zarvollo Lazarus

Tinkaton's hammer

Kodari AI
KodariOct 17 at 1:18 am 1
HammerForge
A Minecraft plugin that adds Tinkaton's hammer as a craftable, powerful weapon. Players can forge the hammer using rare materials, then wield it to deal massive area-of-effect damage with ground slam attacks. The hammer features a charge mechanic where holding right-click builds power, releasing to unleash devastating shockwaves that damage enemies and break blocks. Includes custom crafting recipes, durability system, particle effects, and sound effects. Compatible with Spigot/Paper servers, offering configurable damage values, cooldowns, and recipe customization through YAML configuration files.

Creating Tinkaton’s Hammer as a playful extension for temporarily removing page elements, with an undo button.

Created Tinkaton’s Hammer. On regular websites, turn on bonk mode, click an element to remove it for the current page session, and use the on-page Undo button to restore the last one. Press Esc to stop selecting.

Kodari can make mistakes. Review important code before using.
Files
background.js
content.css
content.js
manifest.json
popup.css
popup.html
popup.js
Code
7 304
content.js
let bonkModeActive = false;
let hoveredElement = null;
let lastBonk = null;
let undoNotice = null;

function clearHighlight() {
  if (hoveredElement) {
    hoveredElement.classList.remove("tinkaton-hammer-hovered");
    hoveredElement = null;
  }
}

function handlePointerOver(event) {
  if (!bonkModeActive) return;
  const element = event.target instanceof HTMLElement ? event.target : null;
  if (!element || element.closest("[data-tinkaton-ui]")) return;
  clearHighlight();
  hoveredElement = element;
  hoveredElement.classList.add("tinkaton-hammer-hovered");
}

function handlePointerOut(event) {
  if (event.target === hoveredElement) {
    clearHighlight();
  }
}

function removeUndoNotice() {
  undoNotice?.remove();
  undoNotice = null;
}

function restoreLastBonk() {
  if (!lastBonk) return;
  const { element, parent, nextSibling } = lastBonk;
  if (parent.isConnected) {
    parent.insertBefore(element, nextSibling?.parentNode === parent ? nextSibling : null);
  }
  lastBonk = null;
  removeUndoNotice();
}

function showUndoNotice() {
  removeUndoNotice();

  const notice = document.createElement("div");
  notice.dataset.tinkatonUi = "undo";
  notice.append(document.createTextNode("Bonk! Element removed."));

  const undoButton = document.createElement("button");
  undoButton.type = "button";
  undoButton.textContent = "Undo";
  undoButton.addEventListener("click", (event) => {
    event.preventDefault();
    event.stopPropagation();
    restoreLastBonk();
  });

  notice.append(undoButton);
  document.documentElement.append(notice);
  undoNotice = notice;
}

function handleClick(event) {
  if (!bonkModeActive) return;
  const element = event.target instanceof HTMLElement ? event.target : null;
  if (!element || element.closest("[data-tinkaton-ui]")) return;
  if (element === document.documentElement || element === document.body) return;

  event.preventDefault();
  event.stopPropagation();
  clearHighlight();
  lastBonk = {
    element,
    parent: element.parentNode,
    nextSibling: element.nextSibling
  };
  element.remove();
  bonkModeActive = false;
  showUndoNotice();
}

function handleKeyDown(event) {
  if (event.key === "Escape" && bonkModeActive) {
    bonkModeActive = false;
    clearHighlight();
  }
}

document.addEventListener("pointerover", handlePointerOver, true);
document.addEventListener("pointerout", handlePointerOut, true);
document.addEventListener("click", handleClick, true);
document.addEventListener("keydown", handleKeyDown, true);

chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
  if (message.type === "tinkaton-status") {
    sendResponse({ active: bonkModeActive });
    return false;
  }

  if (message.type === "tinkaton-toggle") {
    bonkModeActive = !bonkModeActive;
    clearHighlight();
    sendResponse({ active: bonkModeActive });
    return false;
  }

  return false;
});