Advertisement
Guest User

VK Stealth Mode Final

a guest
Apr 30th, 2025
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         VK Stealth Mode Final
  3. // @namespace    http://tampermonkey.net/
  4. // @version      2.8
  5. // @description  Скрывает время, блюрит аватарки и меняет ники
  6. // @author       @CringeCitadel
  7. // @match        https://vk.com/*
  8. // @grant        none
  9. // @require      https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js
  10. // ==/UserScript==
  11.  
  12. (function() {
  13.     'use strict';
  14.  
  15.     const config = {
  16.         enabled: false,
  17.         storageKey: 'vk_stealth_mode_enabled',
  18.         chatSelector: '.ConvoHistory',
  19.         selectors: {
  20.             timeElements: [
  21.                 '.ConvoMessageInfoWithoutBubbles__date'
  22.             ],
  23.             avatarElements: [
  24.                 '.MEAvatar__imgWrapper'
  25.             ],
  26.             nameElements: [
  27.                 '.PeerTitle__title',
  28.                 '.Reply__author'
  29.             ]
  30.         }
  31.     };
  32.  
  33.     // Функция для получения ID текущей учетной записи
  34.     function getCurrentUserId() {
  35.         // Проверяем основную часть чата
  36.         const mainAuthorLink = document.querySelector('a.ConvoMessageHeader__authorLink');
  37.         if (mainAuthorLink) {
  38.             const href = mainAuthorLink.getAttribute('href');
  39.             const idMatch = href.match(/\/id(\d+)/);
  40.             return idMatch ? idMatch[1] : null;
  41.         }
  42.  
  43.         // Проверяем пересланные сообщения
  44.         const replyAuthorLink = document.querySelector('a.Reply__authorLink');
  45.         if (replyAuthorLink) {
  46.             const href = replyAuthorLink.getAttribute('href');
  47.             const idMatch = href.match(/\/id(\d+)/);
  48.             return idMatch ? idMatch[1] : null;
  49.         }
  50.  
  51.         return null;
  52.     }
  53.  
  54.     // Генерация случайной соли
  55.     function generateSalt(length = 16) {
  56.         const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  57.         let salt = '';
  58.         for (let i = 0; i < length; i++) {
  59.             salt += chars.charAt(Math.floor(Math.random() * chars.length));
  60.         }
  61.         return salt;
  62.     }
  63.  
  64.     // Хэширование с использованием соли
  65.     function hashWithSalt(text, salt) {
  66.         return CryptoJS.MD5(text + salt).toString();
  67.     }
  68.  
  69.     // Преобразование хэша в эмодзи
  70.     function hashToEmojis(hash) {
  71.         const emojis = ['😀', '😂', '😎', '🔥', '🌟', '🚀', '💻', '🌍', '🎉', '💡'];
  72.         let result = '';
  73.         for (let i = 0; i < 5; i++) {
  74.             const index = parseInt(hash[i], 16) % emojis.length;
  75.             result += emojis[index];
  76.         }
  77.         return result;
  78.     }
  79.  
  80.     class VKStealth {
  81.         constructor() {
  82.             this.userId = getCurrentUserId();
  83.             this.enabled = localStorage.getItem(config.storageKey) === 'true';
  84.             this.originalStyles = new WeakMap();
  85.             this.originalNames = new WeakMap();
  86.             this.salt = 'vk_stealth_salt_' + Date.now();
  87.             this.init();
  88.         }
  89.  
  90.         init() {
  91.             this.addToggleButton();
  92.             this.restoreState();
  93.         }
  94.  
  95.         addToggleButton() {
  96.             const sidebar = document.querySelector('.HeaderNav');
  97.             if (!sidebar) return;
  98.  
  99.             const toggleBtn = document.createElement('button');
  100.             toggleBtn.id = 'vk_stealth_toggle';
  101.             toggleBtn.style = `
  102.                 background: #fff;
  103.                 border: 1px solid #ccc;
  104.                 padding: 8px 12px;
  105.                 margin: 10px;
  106.                 border-radius: 6px;
  107.                 cursor: pointer;
  108.                 font-size: 12px;
  109.                 color: #000;
  110.                 width: 100%;
  111.                 text-align: left;
  112.             `;
  113.             toggleBtn.textContent = `Стелс-режим: ${this.enabled ? 'ВКЛ' : 'ВЫК'}`;
  114.             toggleBtn.onclick = () => {
  115.                 this.enabled = !this.enabled;
  116.                 localStorage.setItem(config.storageKey, this.enabled);
  117.                 toggleBtn.textContent = `Стелс-режим: ${this.enabled ? 'ВКЛ' : 'ВЫК'}`;
  118.                 this.updateAllElements();
  119.             };
  120.  
  121.             sidebar.appendChild(toggleBtn);
  122.         }
  123.  
  124.         updateAllElements() {
  125.             // Обработка времени
  126.             document.querySelectorAll(config.selectors.timeElements.join(','))
  127.                 .forEach(el => {
  128.                     el.style.display = this.enabled ? 'none' : '';
  129.                 });
  130.  
  131.             // Обработка аватарок
  132.             document.querySelectorAll(config.selectors.avatarElements.join(','))
  133.                 .forEach(el => {
  134.                     if (this.enabled) {
  135.                         if (!this.originalStyles.has(el)) {
  136.                             this.originalStyles.set(el, {
  137.                                 filter: el.style.filter,
  138.                                 opacity: el.style.opacity
  139.                             });
  140.                         }
  141.                         el.style.filter = 'blur(20px)';
  142.                         el.style.opacity = '1';
  143.                     } else {
  144.                         const original = this.originalStyles.get(el);
  145.                         if (original) {
  146.                             el.style.filter = original.filter || '';
  147.                             el.style.opacity = original.opacity || '';
  148.                         }
  149.                     }
  150.                 });
  151.  
  152.             // Обработка никнеймов
  153.             document.querySelectorAll(config.selectors.nameElements.join(','))
  154.                 .forEach(el => {
  155.                     if (this.enabled) {
  156.                         if (!this.originalNames.has(el)) {
  157.                             this.originalNames.set(el, el.textContent);
  158.                         }
  159.  
  160.                         const isSelf = this.isSelfMessage(el);
  161.                         const hash = hashWithSalt(el.textContent, this.salt);
  162.                         const emojiSuffix = hashToEmojis(hash);
  163.                         el.textContent = isSelf ? 'Я' : `Некто${emojiSuffix}`;
  164.                         el.setAttribute('data-nickname-hash', hash);
  165.                     } else {
  166.                         const original = this.originalNames.get(el);
  167.                         if (original !== undefined) {
  168.                             el.textContent = original;
  169.                             el.removeAttribute('data-nickname-hash');
  170.                         }
  171.                     }
  172.                 });
  173.         }
  174.  
  175.         isSelfMessage(el) {
  176.             // Проверка на основное сообщение
  177.             const mainAuthorLink = el.closest('.ConvoMessageWithoutBubble')?.querySelector('.ConvoMessageHeader__authorLink');
  178.             if (mainAuthorLink) {
  179.                 return mainAuthorLink.href.includes(`id${this.userId}`);
  180.             }
  181.  
  182.             // Проверка на пересланные сообщения
  183.             const replyAuthorLink = el.closest('.ConvoMessageWithoutBubble')?.querySelector('.Reply__authorLink');
  184.             if (replyAuthorLink) {
  185.                 return replyAuthorLink.href.includes(`id${this.userId}`);
  186.             }
  187.  
  188.             return false;
  189.         }
  190.  
  191.         restoreState() {
  192.             if (this.enabled) {
  193.                 this.updateAllElements();
  194.             }
  195.         }
  196.     }
  197.  
  198.     new VKStealth();
  199. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement