Advertisement
ArhanJinnah

Death Counter For Evades.io (1.3)

Nov 19th, 2024
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Death Counter
  3. // @namespace    http://tampermonkey.net/
  4. // @version      1.3
  5. // @description  Tracks deaths by map and area, logs them, and allows dynamic interaction.
  6. // @author       ArhaanJinnah
  7. // @match        https://evades.io/*
  8. // @icon         none
  9. // @grant        none
  10. // ==/UserScript==
  11.  
  12. // Objects to track deaths
  13. const playerDeathData = {}; // { playerName: { map: { area: deathCount } } }
  14. const watchedPlayers = new Set(); // Set of players to track
  15. const downedPlayers = new Set(); // Set of currently downed players
  16.  
  17. // Death counter UI container
  18. const counterContainer = document.createElement('div');
  19. counterContainer.style.position = 'fixed';
  20. counterContainer.style.bottom = '10px';
  21. counterContainer.style.right = '10px';
  22. counterContainer.style.backgroundColor = '#333';
  23. counterContainer.style.color = '#fff';
  24. counterContainer.style.padding = '10px';
  25. counterContainer.style.borderRadius = '5px';
  26. counterContainer.style.display = 'none';
  27. counterContainer.style.display = 'flex';
  28. counterContainer.style.flexDirection = 'column';
  29. counterContainer.style.alignItems = 'flex-start';
  30. document.body.appendChild(counterContainer);
  31.  
  32. // Reset button
  33. const resetButton = document.createElement('button');
  34. resetButton.innerText = 'Reset';
  35. resetButton.style.padding = '5px';
  36. resetButton.style.cursor = 'pointer';
  37. resetButton.style.backgroundColor = '#ff5c5c';
  38. resetButton.style.color = '#fff';
  39. resetButton.style.border = 'none';
  40. resetButton.style.borderRadius = '5px';
  41. resetButton.addEventListener('click', () => {
  42.     watchedPlayers.forEach(playerName => {
  43.         playerDeathData[playerName] = {};
  44.     });
  45.     updateDeathCounters();
  46. });
  47.  
  48. // Create the Toggle Size Button
  49. const toggleSizeButton = document.createElement('button');
  50. toggleSizeButton.innerText = 'Toggle';
  51. toggleSizeButton.style.padding = '5px';
  52. toggleSizeButton.style.cursor = 'pointer';
  53. toggleSizeButton.style.backgroundColor = '#4CAF50';
  54. toggleSizeButton.style.color = '#fff';
  55. toggleSizeButton.style.border = 'none';
  56. toggleSizeButton.style.borderRadius = '5px';
  57.  
  58. let isSmall = false;
  59. toggleSizeButton.addEventListener('click', () => {
  60.     if (isSmall) {
  61.         counterContainer.style.width = 'auto';
  62.         counterContainer.style.height = 'auto';
  63.         counterContainer.style.padding = '10px';
  64.         resetButton.style.display = 'block';
  65.     } else {
  66.         counterContainer.style.width = '5px';
  67.         counterContainer.style.height = '5px';
  68.         counterContainer.style.padding = '5px';
  69.         resetButton.style.display = 'none';
  70.     }
  71.     isSmall = !isSmall;
  72. });
  73.  
  74. // Button container
  75. const buttonContainer = document.createElement('div');
  76. buttonContainer.style.display = 'flex';
  77. buttonContainer.style.alignItems = 'center';
  78. buttonContainer.appendChild(resetButton);
  79. buttonContainer.appendChild(toggleSizeButton);
  80.  
  81. counterContainer.appendChild(buttonContainer);
  82.  
  83. // Update death counters UI
  84. function updateDeathCounters() {
  85.     counterContainer.innerHTML = '';
  86.     counterContainer.appendChild(buttonContainer);
  87.  
  88.     if (watchedPlayers.size > 0) {
  89.         counterContainer.style.display = 'block';
  90.         watchedPlayers.forEach(playerName => {
  91.             const playerData = playerDeathData[playerName] || {};
  92.             const mapDeaths = Object.keys(playerData).reduce((total, map) => {
  93.                 const mapData = playerData[map];
  94.                 return total + Object.values(mapData).reduce((sum, deaths) => sum + deaths, 0);
  95.             }, 0);
  96.  
  97.             const playerDiv = document.createElement('div');
  98.             playerDiv.innerText = `${playerName}: ${mapDeaths} deaths`;
  99.             playerDiv.style.marginBottom = '5px';
  100.             playerDiv.style.cursor = 'pointer';
  101.  
  102.             // Left-click to show Death Log
  103.             playerDiv.addEventListener('click', () => showDeathLog(playerName));
  104.  
  105.             // Right-click context menu for removing player
  106.             playerDiv.addEventListener('contextmenu', (event) => {
  107.                 event.preventDefault(); // Prevent the default right-click menu
  108.                
  109.                 // Create custom context menu
  110.                 const contextMenu = document.createElement('div');
  111.                 contextMenu.style.position = 'absolute';
  112.                 contextMenu.style.top = `${event.clientY}px`;
  113.                 contextMenu.style.left = `${event.clientX}px`;
  114.                 contextMenu.style.backgroundColor = '#333';
  115.                 contextMenu.style.color = '#fff';
  116.                 contextMenu.style.padding = '10px';
  117.                 contextMenu.style.borderRadius = '5px';
  118.                 contextMenu.style.boxShadow = '0 4px 10px rgba(0, 0, 0, 0.5)';
  119.                 contextMenu.style.zIndex = '1000';
  120.  
  121.                 // Add "Remove" option to context menu
  122.                 const removeOption = document.createElement('div');
  123.                 removeOption.innerText = 'Remove from Death Counter';
  124.                 removeOption.style.cursor = 'pointer';
  125.                 removeOption.style.padding = '5px';
  126.                 removeOption.style.borderBottom = '1px solid #fff';
  127.                 removeOption.addEventListener('click', () => {
  128.                     watchedPlayers.delete(playerName);
  129.                     updateDeathCounters();
  130.                     document.body.removeChild(contextMenu); // Close the context menu
  131.                 });
  132.  
  133.                 contextMenu.appendChild(removeOption);
  134.                 document.body.appendChild(contextMenu);
  135.  
  136.                 // Close the menu if clicking outside
  137.                 document.addEventListener('click', () => {
  138.                     document.body.removeChild(contextMenu);
  139.                 }, { once: true });
  140.             });
  141.  
  142.             counterContainer.appendChild(playerDiv);
  143.         });
  144.     } else {
  145.         counterContainer.style.display = 'none';
  146.     }
  147. }
  148.  
  149. // Show detailed Death Log
  150. function showDeathLog(playerName) {
  151.     const log = playerDeathData[playerName] || {};
  152.     const logContainer = document.createElement('div');
  153.     logContainer.style.position = 'fixed';
  154.     logContainer.style.top = '50%';
  155.     logContainer.style.left = '50%';
  156.     logContainer.style.transform = 'translate(-50%, -50%)';
  157.     logContainer.style.backgroundColor = '#333';
  158.     logContainer.style.color = '#fff';
  159.     logContainer.style.padding = '20px';
  160.     logContainer.style.borderRadius = '10px';
  161.     logContainer.style.zIndex = '1000';
  162.     logContainer.style.whiteSpace = 'pre-wrap';
  163.     logContainer.style.textAlign = 'left';
  164.     logContainer.style.maxHeight = '70%';
  165.     logContainer.style.overflowY = 'auto';
  166.     logContainer.style.boxShadow = '0 4px 10px rgba(0, 0, 0, 0.5)';
  167.  
  168.     // Title
  169.     const title = document.createElement('h2');
  170.     title.innerText = `Death Log for ${playerName}`;
  171.     title.style.marginBottom = '10px';
  172.     logContainer.appendChild(title);
  173.  
  174.     // Map and area breakdown
  175.     Object.entries(log).forEach(([map, areas]) => {
  176.         const mapEntry = document.createElement('div');
  177.         mapEntry.style.marginBottom = '5px';
  178.         mapEntry.style.cursor = 'pointer';
  179.         mapEntry.style.fontWeight = 'bold';
  180.         mapEntry.innerText = `${map}: ${Object.values(areas).reduce((sum, deaths) => sum + deaths, 0)} deaths`;
  181.  
  182.         const areaContainer = document.createElement('div');
  183.         areaContainer.style.marginTop = '5px';
  184.         areaContainer.style.paddingLeft = '10px';
  185.         areaContainer.style.display = 'none'; // Hidden by default
  186.  
  187.         Object.entries(areas).forEach(([area, deaths]) => {
  188.             const areaEntry = document.createElement('div');
  189.             areaEntry.style.marginBottom = '3px';
  190.             areaEntry.innerText = `- ${area}: ${deaths} deaths`;
  191.             areaContainer.appendChild(areaEntry);
  192.         });
  193.  
  194.         // Toggle area breakdown on click
  195.         mapEntry.addEventListener('click', () => {
  196.             areaContainer.style.display = areaContainer.style.display === 'none' ? 'block' : 'none';
  197.         });
  198.  
  199.         logContainer.appendChild(mapEntry);
  200.         logContainer.appendChild(areaContainer);
  201.     });
  202.  
  203.     // Close button
  204.     const closeButton = document.createElement('button');
  205.     closeButton.innerText = 'Close';
  206.     closeButton.style.marginTop = '10px';
  207.     closeButton.style.padding = '5px 10px';
  208.     closeButton.style.cursor = 'pointer';
  209.     closeButton.style.backgroundColor = '#ff5c5c';
  210.     closeButton.style.color = '#fff';
  211.     closeButton.style.border = 'none';
  212.     closeButton.style.borderRadius = '5px';
  213.     closeButton.addEventListener('click', () => {
  214.         document.body.removeChild(logContainer);
  215.     });
  216.  
  217.     logContainer.appendChild(closeButton);
  218.     document.body.appendChild(logContainer);
  219. }
  220.  
  221. // Check leaderboard for downed players
  222. function checkLeaderboard() {
  223.     const leaderboardLines = document.querySelectorAll('#leaderboard .leaderboard-line');
  224.     const currentDownedPlayers = new Set();
  225.  
  226.     leaderboardLines.forEach(line => {
  227.         const title = line.getAttribute('title');
  228.         const playerName = title.split(' [')[0];
  229.         const map = line.classList[1].replace(/-/g, ' ');
  230.         const area = title.match(/\[(.*?)\]/)?.[1] || 'Unknown Area';
  231.  
  232.         if (playerName) {
  233.             if (!line.querySelector('.track-button')) {
  234.                 const trackButton = document.createElement('button');
  235.                 trackButton.innerText = 'Track';
  236.                 trackButton.classList.add('track-button');
  237.                 trackButton.style.marginLeft = '10px';
  238.                 trackButton.style.padding = '3px 8px';
  239.                 trackButton.style.cursor = 'pointer';
  240.                 trackButton.style.backgroundColor = '#4CAF50';
  241.                 trackButton.style.color = '#fff';
  242.                 trackButton.style.border = 'none';
  243.                 trackButton.style.borderRadius = '5px';
  244.  
  245.                 trackButton.addEventListener('click', () => {
  246.                     if (!watchedPlayers.has(playerName)) {
  247.                         watchedPlayers.add(playerName);
  248.                         trackButton.innerText = 'Untrack';
  249.                         trackButton.style.backgroundColor = '#ff5c5c';
  250.                     } else {
  251.                         watchedPlayers.delete(playerName);
  252.                         trackButton.innerText = 'Track';
  253.                         trackButton.style.backgroundColor = '#4CAF50';
  254.                     }
  255.                     updateDeathCounters();
  256.                 });
  257.  
  258.                 const playerNameElement = line.querySelector('.leaderboard-name');
  259.                 if (playerNameElement) {
  260.                     playerNameElement.appendChild(trackButton);
  261.                 }
  262.             }
  263.         }
  264.  
  265.         if (line.classList.contains('leaderboard-downed')) {
  266.             if (playerName && watchedPlayers.has(playerName)) {
  267.                 if (!downedPlayers.has(playerName)) {
  268.                     if (!playerDeathData[playerName]) playerDeathData[playerName] = {};
  269.                     if (!playerDeathData[playerName][map]) playerDeathData[playerName][map] = {};
  270.                     playerDeathData[playerName][map][area] = (playerDeathData[playerName][map][area] || 0) + 1;
  271.  
  272.                     updateDeathCounters();
  273.                 }
  274.                 currentDownedPlayers.add(playerName);
  275.             }
  276.         }
  277.     });
  278.  
  279.     downedPlayers.clear();
  280.     currentDownedPlayers.forEach(player => downedPlayers.add(player));
  281. }
  282.  
  283. // Disable 'B' key for leaderboard deletion
  284. document.addEventListener('keydown', event => {
  285.     if (event.key.toLowerCase() === 'b') {
  286.         event.stopPropagation();
  287.         event.preventDefault();
  288.     }
  289. });
  290.  
  291. // Toggle leaderboard visibility
  292. const leaderboard = document.getElementById('leaderboard');
  293. leaderboard.style.visibility = 'hidden';
  294.  
  295. const toggleLeaderboardButton = document.createElement('button');
  296. toggleLeaderboardButton.textContent = 'Toggle Leaderboard';
  297. toggleLeaderboardButton.style.position = 'absolute';
  298. toggleLeaderboardButton.style.left = '10px';
  299. toggleLeaderboardButton.style.top = '50px';
  300. toggleLeaderboardButton.style.zIndex = '1000';
  301.  
  302. let isLeaderboardVisible = false;
  303.  
  304. function updateButtonColor() {
  305.     toggleLeaderboardButton.style.backgroundColor = isLeaderboardVisible ? 'green' : 'red';
  306. }
  307.  
  308. updateButtonColor();
  309.  
  310. toggleLeaderboardButton.addEventListener('click', () => {
  311.     isLeaderboardVisible = !isLeaderboardVisible;
  312.     leaderboard.style.visibility = isLeaderboardVisible ? 'visible' : 'hidden';
  313.     updateButtonColor();
  314. });
  315.  
  316. const leaderboardObserver = new MutationObserver(() => {
  317.     if (!isLeaderboardVisible) leaderboard.style.visibility = 'hidden';
  318. });
  319.  
  320. leaderboardObserver.observe(leaderboard, { attributes: true, childList: true, subtree: true });
  321.  
  322. document.body.appendChild(toggleLeaderboardButton);
  323.  
  324. // Check leaderboard periodically
  325. setInterval(checkLeaderboard, 100);
  326.  
  327. // Initialize with some watched players
  328. watchedPlayers.add('ArhaanJinnah');
  329. updateDeathCounters();
  330.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement