Bonk.io Top Hat Userscript

Adds a top hat to all players in Bonk.io

当前为 2023-10-08 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bonk.io Top Hat Userscript
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Adds a top hat to all players in Bonk.io
  6. // @author Studz
  7. // @match https://bonk.io/
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Define the CSS for the top hat
  15. var topHatStyle = `
  16. .player {
  17. position: relative;
  18. }
  19.  
  20. .top-hat {
  21. position: absolute;
  22. width: 30px;
  23. height: 20px;
  24. background-color: black;
  25. top: -20px;
  26. left: 50%;
  27. transform: translateX(-50%);
  28. }
  29. `;
  30.  
  31. // Create a style element and append it to the document
  32. var styleElement = document.createElement('style');
  33. styleElement.innerHTML = topHatStyle;
  34. document.head.appendChild(styleElement);
  35.  
  36. // Add a top hat to each player
  37. var players = document.querySelectorAll('.player');
  38. players.forEach(function(player) {
  39. var topHat = document.createElement('div');
  40. topHat.classList.add('top-hat');
  41. player.appendChild(topHat);
  42. });
  43. })();