Free PixelPlace Player Tracker

Provides all free users of pixelplace with a Player Tracking feature! There are no hidden tricks.

目前為 2023-08-13 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Free PixelPlace Player Tracker
// @description  Provides all free users of pixelplace with a Player Tracking feature! There are no hidden tricks.
// @version      1.0.0
// @author       WhithoutArms
// @match        https://pixelplace.io/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=pixelplace.io
// @grant        none
// @run-at       document-end
// @namespace https://greasyfork.org/users/1150187
// ==/UserScript==


/*

AT THE CURRENT MOMENT THE SCRIPT ONLY WORKS ON /7, FUTURE PLANS WILL EXTEND TO MORE CANVASES


KIND PIXELPLACE USER,
THIS SCRIPT CONNECTS TO AN EXTERNAL WEBSITE.
YOUR ACCOUNT INFO, IS NOT SHARED. THERE IS NO DATA ABOUT YOU SENT.

THE ONLY DATA THAT CAN BE GATHERED BY THE SERVER IS YOUR IP ADDRESS.
IP ADDRESSES ARE STORED IN MEMORY FOR CONNECTION LIMIT, AND DELETED AS SOON AS YOU STOP USING THE SCRIPT/PIXELPLACE.

ABSOLUTELY NO INFO IS SAVED ON THE SERVER SIDE.
*/


Object.defineProperty(window.console, 'log', {
  configurable: false,
  enumerable: true,
  writable: false,
  value: console.log
});


const userTrackerMap = {};
const trackerUpdateInterval = 5000;
console.log("Opening a Web Socket!");

const mysocket = new WebSocket('wss://de4lua.art:2083');

mysocket.addEventListener('message', function (event) {
  const message = event.data;

  if (message.startsWith("1")) {
    const idAndUsername = message.substring(1);
    const parts = idAndUsername.split('_');

    if (parts.length >= 2) {
      const id = parts[1];
      const username = parts[0];

      if (!userTrackerMap[id]) {
        const tracker = createTrackerElement(username);
        userTrackerMap[id] = { element: tracker, lastUpdate: Date.now() };
        appendTracker(tracker);
      } else {
        userTrackerMap[id].lastUpdate = Date.now();
      }
    }
  } else {
    const pixelData = JSON.parse(event.data);
    for (const pixel of pixelData) {
      const x = pixel[0];
      const y = pixel[1];
      const id = pixel[3];

      if (!userTrackerMap[id]) {
        mysocket.send(`1${id}`);
      } else {
        const trackerElement = userTrackerMap[id].element;
        trackerElement.style.left = (x+1) + 'px';
        trackerElement.style.top = (y+1) + 'px';
        userTrackerMap[id].lastUpdate = Date.now();
      }
    }
  }

  for (const userId in userTrackerMap) {
    if (Date.now() - userTrackerMap[userId].lastUpdate > trackerUpdateInterval) {
      removeTracker(userId);
    }
  }
});

function createTrackerElement(username) {
  const trackerElement = document.createElement('div');
  trackerElement.className = 'track open-profile';
  trackerElement.style = 'display: block; border-color: rgb(255, 255, 255);';
  trackerElement.setAttribute('data-profile', username);
  trackerElement.textContent = username;
  return trackerElement;
}

function appendTracker(trackerElement) {
  const paintingMoveElement = document.getElementById('painting-move');
  if (paintingMoveElement) {
    paintingMoveElement.appendChild(trackerElement);
  }
}

function removeTracker(userId) {
  if (userTrackerMap[userId] && userTrackerMap[userId].element) {
    userTrackerMap[userId].element.remove();
    delete userTrackerMap[userId];
  }
}