Diep.io Join Notifier

Notifies when people join,leave,respawn or die using the inbuilt diep.io player list.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         Diep.io Join Notifier
// @namespace    *
// @version      1.1.6
// @description  Notifies when people join,leave,respawn or die using the inbuilt diep.io player list.
// @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 = {};
let times = {};
function toMin(millis) {
  var minutes = Math.floor(millis / 60000);
  var seconds = ((millis % 60000) / 1000).toFixed(0);
  return minutes + ":" + (seconds < 10 ? '0' : '') + seconds;
}
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`);
                    times[player.identityId] = {};
                }
                if (oldPlayers[player.identityId]) {
                    if (oldPlayers[player.identityId].name !== ' (dead)' && player.name === ' (dead)') {
                        oldNames[player.identityId] = oldPlayers[player.identityId].name;
                      if (dieNotifications && times[player.identityId].spawnTime) notification(`${oldPlayers[player.identityId].name} died (${toMin(new Date().getTime()-times[player.identityId].spawnTime)})`)
                        if (dieNotifications && !times[player.identityId].spawnTime) 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
                        }
                        times[player.identityId] = {};
                        times[player.identityId].spawnTime = new Date().getTime();
                        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(`${playr.name} 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 = `&nbsp;${text}&nbsp;`;
    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";
        button.style.opacity = "0";

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