Diep.io Join Notifier

Notifies when people join,leave,respawn or die using the inbuilt diep.io player list. (note: if it says {not updated} as name, they left while dead before we saw real name)

Mint 2024.03.02.. Lásd a legutóbbi verzió

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Diep.io Join Notifier
// @namespace    *
// @version      1.1.4
// @description  Notifies when people join,leave,respawn or die using the inbuilt diep.io player list. (note: if it says {not updated} as name, they left while dead before we saw real name)
// @author       rbest
// @match        https://diep.io/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=diep.io
// @license      rbest
// @grant        none
// ==/UserScript==
// made by king rbest
// made by king rbest
// made by king rbest
//toggle which notifications you want
let joinNotifications = true;
let dieNotifications = true;
let respawnNotifications = true;
let leaveNotifications = true;
//dont touch this;
let old = [];
let bef = [];
let changed = false;
let oldPlayers = {};
let oldNames = {};
function check() {
    let players = window.ui.players;
    let players2 = {};
    players.forEach(player=>{
        players2[player.identityId] = player;
    })
    if (players) {
        bef = old;
        oldPlayers = {};
        bef.forEach(player=>{
            oldPlayers[player.identityId] = player;
        })
        old = players;
        if (bef===old) changed = false;
        if (bef!==old) changed = true;
        if (changed === true) {
            for (let player of players) {
                if (!oldPlayers[player.identityId]) {
                    if (joinNotifications) notification(`${player.name} joined`);
                }
                if (oldPlayers[player.identityId]) {
                    if (oldPlayers[player.identityId].name !== ' (dead)' && player.name === ' (dead)') {
                        oldNames[player.identityId] = oldPlayers[player.identityId].name;
                      if (dieNotifications) notification(`${oldPlayers[player.identityId].name} died`)
                    }
                    if (oldPlayers[player.identityId].name === ' (dead)' && player.name !== ' (dead)') {
                        if (player.name === oldNames[player.identityId]) {
                           if (respawnNotifications) notification(`${player.name} respawned`);
                        }
                        else if (player.name !== oldNames[player.identityId] && oldNames[player.identityId] !== undefined) {
                          if (respawnNotifications) notification(`${player.name} (${oldNames[player.identityId]}) respawned`); //if they changed username
                        }
                        oldNames[player.identityId] = player.name;
                    }
                }
            }
            Object.values(oldPlayers).forEach(playr=>{
                if (!players2[playr.identityId] && oldNames[playr.identityId] !== undefined) if (leaveNotifications) notification(`${oldNames[playr.identityId]} left`);
                if (!players2[playr.identityId] && oldNames[playr.identityId] === undefined) if (leaveNotifications) notification('{not updated} left');
            })
        }
    }
}
setInterval(check,100);
//Modified notification code from DiepBox
let notificationBody = document.body.appendChild(document.createElement('div'));
notificationBody.style.pointerEvents = 'none';
notificationBody.style.position = 'fixed';
notificationBody.style.left = `50%`;
notificationBody.style.top = `1.9%`;
notificationBody.style.opacity = '0.70';

function notification(text, duration = 3500) {
    const button = document.createElement('button');
    button.innerHTML = ` ${text} `;
    button.style['background-color'] = '#E8B18B';
    button.style.display = 'block';
    button.style.height = '35px';
    button.style.border = 'none';
    button.style.color = 'white';
    button.style.fontSize = '26px';
    button.style.transform = 'translate(-50%, -1.9%)';
    button.addEventListener('contextmenu', (e) => e.preventDefault());

    notificationBody.appendChild(button);
    setTimeout(()=>{
        button.style.transition = "opacity 250ms ease";
        button.style.opacity = "0";

        setTimeout(() => button.remove(), 250);
    },duration);
}
// made by king rbest