Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name VK Stealth Mode Final
- // @namespace http://tampermonkey.net/
- // @version 2.8
- // @description Скрывает время, блюрит аватарки и меняет ники
- // @author @CringeCitadel
- // @match https://vk.com/*
- // @grant none
- // @require https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js
- // ==/UserScript==
- (function() {
- 'use strict';
- const config = {
- enabled: false,
- storageKey: 'vk_stealth_mode_enabled',
- chatSelector: '.ConvoHistory',
- selectors: {
- timeElements: [
- '.ConvoMessageInfoWithoutBubbles__date'
- ],
- avatarElements: [
- '.MEAvatar__imgWrapper'
- ],
- nameElements: [
- '.PeerTitle__title',
- '.Reply__author'
- ]
- }
- };
- // Функция для получения ID текущей учетной записи
- function getCurrentUserId() {
- // Проверяем основную часть чата
- const mainAuthorLink = document.querySelector('a.ConvoMessageHeader__authorLink');
- if (mainAuthorLink) {
- const href = mainAuthorLink.getAttribute('href');
- const idMatch = href.match(/\/id(\d+)/);
- return idMatch ? idMatch[1] : null;
- }
- // Проверяем пересланные сообщения
- const replyAuthorLink = document.querySelector('a.Reply__authorLink');
- if (replyAuthorLink) {
- const href = replyAuthorLink.getAttribute('href');
- const idMatch = href.match(/\/id(\d+)/);
- return idMatch ? idMatch[1] : null;
- }
- return null;
- }
- // Генерация случайной соли
- function generateSalt(length = 16) {
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
- let salt = '';
- for (let i = 0; i < length; i++) {
- salt += chars.charAt(Math.floor(Math.random() * chars.length));
- }
- return salt;
- }
- // Хэширование с использованием соли
- function hashWithSalt(text, salt) {
- return CryptoJS.MD5(text + salt).toString();
- }
- // Преобразование хэша в эмодзи
- function hashToEmojis(hash) {
- const emojis = ['😀', '😂', '😎', '🔥', '🌟', '🚀', '💻', '🌍', '🎉', '💡'];
- let result = '';
- for (let i = 0; i < 5; i++) {
- const index = parseInt(hash[i], 16) % emojis.length;
- result += emojis[index];
- }
- return result;
- }
- class VKStealth {
- constructor() {
- this.userId = getCurrentUserId();
- this.enabled = localStorage.getItem(config.storageKey) === 'true';
- this.originalStyles = new WeakMap();
- this.originalNames = new WeakMap();
- this.salt = 'vk_stealth_salt_' + Date.now();
- this.init();
- }
- init() {
- this.addToggleButton();
- this.restoreState();
- }
- addToggleButton() {
- const sidebar = document.querySelector('.HeaderNav');
- if (!sidebar) return;
- const toggleBtn = document.createElement('button');
- toggleBtn.id = 'vk_stealth_toggle';
- toggleBtn.style = `
- background: #fff;
- border: 1px solid #ccc;
- padding: 8px 12px;
- margin: 10px;
- border-radius: 6px;
- cursor: pointer;
- font-size: 12px;
- color: #000;
- width: 100%;
- text-align: left;
- `;
- toggleBtn.textContent = `Стелс-режим: ${this.enabled ? 'ВКЛ' : 'ВЫК'}`;
- toggleBtn.onclick = () => {
- this.enabled = !this.enabled;
- localStorage.setItem(config.storageKey, this.enabled);
- toggleBtn.textContent = `Стелс-режим: ${this.enabled ? 'ВКЛ' : 'ВЫК'}`;
- this.updateAllElements();
- };
- sidebar.appendChild(toggleBtn);
- }
- updateAllElements() {
- // Обработка времени
- document.querySelectorAll(config.selectors.timeElements.join(','))
- .forEach(el => {
- el.style.display = this.enabled ? 'none' : '';
- });
- // Обработка аватарок
- document.querySelectorAll(config.selectors.avatarElements.join(','))
- .forEach(el => {
- if (this.enabled) {
- if (!this.originalStyles.has(el)) {
- this.originalStyles.set(el, {
- filter: el.style.filter,
- opacity: el.style.opacity
- });
- }
- el.style.filter = 'blur(20px)';
- el.style.opacity = '1';
- } else {
- const original = this.originalStyles.get(el);
- if (original) {
- el.style.filter = original.filter || '';
- el.style.opacity = original.opacity || '';
- }
- }
- });
- // Обработка никнеймов
- document.querySelectorAll(config.selectors.nameElements.join(','))
- .forEach(el => {
- if (this.enabled) {
- if (!this.originalNames.has(el)) {
- this.originalNames.set(el, el.textContent);
- }
- const isSelf = this.isSelfMessage(el);
- const hash = hashWithSalt(el.textContent, this.salt);
- const emojiSuffix = hashToEmojis(hash);
- el.textContent = isSelf ? 'Я' : `Некто${emojiSuffix}`;
- el.setAttribute('data-nickname-hash', hash);
- } else {
- const original = this.originalNames.get(el);
- if (original !== undefined) {
- el.textContent = original;
- el.removeAttribute('data-nickname-hash');
- }
- }
- });
- }
- isSelfMessage(el) {
- // Проверка на основное сообщение
- const mainAuthorLink = el.closest('.ConvoMessageWithoutBubble')?.querySelector('.ConvoMessageHeader__authorLink');
- if (mainAuthorLink) {
- return mainAuthorLink.href.includes(`id${this.userId}`);
- }
- // Проверка на пересланные сообщения
- const replyAuthorLink = el.closest('.ConvoMessageWithoutBubble')?.querySelector('.Reply__authorLink');
- if (replyAuthorLink) {
- return replyAuthorLink.href.includes(`id${this.userId}`);
- }
- return false;
- }
- restoreState() {
- if (this.enabled) {
- this.updateAllElements();
- }
- }
- }
- new VKStealth();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement