Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Twitch unique active chatters count
- // @namespace http://tampermonkey.net/
- // @version 0.2
- // @description Ilyukha Mad Baza
- // @author Tredovsky
- // @match https://www.twitch.tv/*
- // @icon https://www.google.com/s2/favicons?sz=64&domain=twitch.tv
- // @grant none
- // @updateURL https://pastebin.com/raw/xbtgiN8v
- // @downloadURL https://pastebin.com/raw/xbtgiN8v
- // ==/UserScript==
- (function() {
- 'use strict';
- let date = new Date().toLocaleString();
- const UPDATE_PERIOD_MS = 3000;
- let nameSet = new Set();
- let chattersCountEl;
- let streamerPathname = window.location.pathname;
- setInterval(() => {
- const nameElements = document.getElementsByClassName('chat-author__display-name');
- const names = [...nameElements].map(ne => ne.innerText);
- if (window.location.pathname === streamerPathname) {
- nameSet = nameSet.union(new Set(names));
- } else {
- nameSet = new Set(names);
- date = new Date().toLocaleString();
- streamerPathname = window.location.pathname;
- }
- console.log(`Unique chatters in chat: ${nameSet.size}`);
- const viewerCountEl = document.querySelector('[data-a-target="animated-channel-viewers-count"]')?.parentElement;
- if (!viewerCountEl) return;
- if (chattersCountEl && viewerCountEl.contains(chattersCountEl)) viewerCountEl.removeChild(chattersCountEl);
- chattersCountEl = document.createElement('p');
- chattersCountEl.innerText = `(${nameSet.size})`;
- chattersCountEl.title = `Начиная с ${date}`;
- viewerCountEl.appendChild(chattersCountEl);
- }, UPDATE_PERIOD_MS);
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement