Guest User

Мелкобукву нахуй

a guest
Jan 30th, 2026
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 3.58 KB | Cybersecurity | 0 0
  1. // ==UserScript==
  2. // @name         Мелкобуква нахуй с двачей
  3. // @namespace    2ch-lowercase-filter
  4. // @match        *://2ch.su/*
  5. // @grant        none
  6. // ==/UserScript==
  7.  
  8. (function () {
  9.     'use strict';
  10.  
  11.     const badPostIds = new Set();
  12.  
  13.     function getPostId(post) {
  14.         return post.id ? post.id.replace(/\D/g, '') : null;
  15.     }
  16.  
  17.     function getRealLines(node) {
  18.         const walker = document.createTreeWalker(
  19.             node,
  20.             NodeFilter.SHOW_TEXT,
  21.             null
  22.         );
  23.  
  24.         const lines = [];
  25.         let n;
  26.  
  27.         while ((n = walker.nextNode())) {
  28.             const parts = n.nodeValue.split('\n');
  29.             for (let p of parts) {
  30.                 const t = p.trim();
  31.                 if (t) lines.push(t);
  32.             }
  33.         }
  34.  
  35.         return lines;
  36.     }
  37.  
  38.     function collapseHide(post) {
  39.         post.style.height = "0px";
  40.         post.style.overflow = "hidden";
  41.         post.style.opacity = "0";
  42.         post.style.margin = "0";
  43.         post.style.padding = "0";
  44.         post.style.border = "0";
  45.     }
  46.  
  47.     function processPosts() {
  48.  
  49.         // ===== PASS 1 — классификация =====
  50.  
  51.         document.querySelectorAll('.post').forEach(post => {
  52.             if (post.dataset.lowercaseChecked) return;
  53.  
  54.             const msg = post.querySelector('.post__message');
  55.             if (!msg) return;
  56.  
  57.             const fullText = msg.textContent || '';
  58.  
  59.             // ---- OP override ----
  60.             const opMatches = fullText.match(/>>\d+\s*\(OP\)/g);
  61.             if (opMatches && opMatches.length >= 2) {
  62.                 post.style.outline = '3px solid #00cc66';
  63.                 post.style.background = 'rgba(0,255,120,0.10)';
  64.                 msg.style.color = '#33dd88';
  65.  
  66.                 post.dataset.filterState = "good";
  67.                 post.dataset.lowercaseChecked = "1";
  68.                 return;
  69.             }
  70.  
  71.             const lines = getRealLines(msg);
  72.             const filtered = lines.filter(l =>
  73.                 !l.startsWith('>') && !l.startsWith('>>')
  74.             );
  75.  
  76.             if (filtered.length) {
  77.                 const firstChar = filtered[0].charAt(0);
  78.  
  79.                 if (/[а-яё]/.test(firstChar)) {
  80.                     const id = getPostId(post);
  81.                     if (id) badPostIds.add(id);
  82.  
  83.                     collapseHide(post);
  84.                     post.dataset.filterState = "bad";
  85.                 }
  86.             }
  87.  
  88.             post.dataset.lowercaseChecked = "1";
  89.         });
  90.  
  91.         // ===== PASS 2 — красим ссылки =====
  92.  
  93.         document.querySelectorAll('a').forEach(a => {
  94.             const m = a.textContent.match(/^>>(\d+)$/);
  95.             if (!m) return;
  96.  
  97.             if (badPostIds.has(m[1])) {
  98.                 a.style.color = "#ff4444";
  99.             }
  100.         });
  101.  
  102.         // ===== PASS 3 — чистим reply =====
  103.  
  104.         document.querySelectorAll('.post').forEach(post => {
  105.             const boxes = post.querySelectorAll(
  106.                 '.post__replies, .reflinks, .post__refmap, .post__replymap'
  107.             );
  108.  
  109.             boxes.forEach(box => {
  110.                 box.querySelectorAll('a').forEach(a => {
  111.                     const m = a.textContent.match(/>>(\d+)/);
  112.                     if (m && badPostIds.has(m[1])) {
  113.                         a.remove();
  114.                     }
  115.                 });
  116.             });
  117.         });
  118.     }
  119.  
  120.     processPosts();
  121.  
  122.     const observer = new MutationObserver(processPosts);
  123.     observer.observe(document.body, { childList: true, subtree: true });
  124.  
  125. })();
  126.  
Advertisement
Add Comment
Please, Sign In to add comment