Guest User

Untitled

a guest
Jun 24th, 2024
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Tiltólista kezelő (forum.sodika.org)
  3. // @namespace    Violentmonkey Scripts
  4. // @match        https://forum.sodika.org/*
  5. // @grant        GM.getValue
  6. // @grant        GM.setValue
  7. // @require      https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js
  8. // @version      1.03
  9. // @author       Kiss Endre Farkas - elítélt bűnöző, okirat hamisító, csaló
  10. // @description  Tiltólista kezelő a fórumomhoz, maradjmár. https://sodipedia.sodika.org/
  11. // ==/UserScript==
  12.  
  13. //let myDate = MIFFAN???
  14. (async function ($) {
  15.     'use strict';
  16.  
  17.     // Blacklist betöjtése, ejjenőjzés és tömppé ajakítás
  18.     let blacklist = await GM.getValue('blacklist', []);
  19.     if (!Array.isArray(blacklist)) {
  20.         blacklist = blacklist ? blacklist.split(',').map(name => name.trim()) : [];
  21.         GM.setValue('blacklist', blacklist);
  22.     }
  23.  
  24.     // Fejugjó apjak jétjehozása
  25.     const popup = document.createElement('div');
  26.     popup.style.display = 'none';
  27.     popup.style.position = 'fixed';
  28.     popup.style.top = '50%';
  29.     popup.style.left = '50%';
  30.     popup.style.transform = 'translate(-50%, -50%)';
  31.     popup.style.backgroundColor = '#fff';
  32.     popup.style.padding = '20px';
  33.     popup.style.borderRadius = '8px';
  34.     popup.style.boxShadow = '0 2px 10px rgba(0,0,0,0.2)';
  35.     popup.style.zIndex = '10000';
  36.     popup.style.width = '400px';
  37.     popup.style.maxHeight = '80vh';
  38.     popup.style.overflowY = 'auto';
  39.     document.body.appendChild(popup);
  40.  
  41.     const title = document.createElement('h3');
  42.     title.textContent = 'Tiltólista kezelése';
  43.     title.style.textAlign = 'center';
  44.     title.style.marginBottom = '20px';
  45.     title.style.color = '#333';
  46.     popup.appendChild(title);
  47.  
  48.     const userList = document.createElement('div');
  49.     userList.style.display = 'flex';
  50.     userList.style.flexWrap = 'wrap';
  51.     userList.style.gap = '10px';
  52.     popup.appendChild(userList);
  53.  
  54.     // Pezájás gomp
  55.     const closeButton = document.createElement('span');
  56.     closeButton.textContent = '✕';
  57.     closeButton.style.position = 'absolute';
  58.     closeButton.style.top = '10px';
  59.     closeButton.style.right = '10px';
  60.     closeButton.style.cursor = 'pointer';
  61.     closeButton.style.fontSize = '18px';
  62.     closeButton.style.color = '#666';
  63.     closeButton.addEventListener('click', () => {
  64.         popup.style.display = 'none';
  65.     });
  66.     popup.appendChild(closeButton);
  67.  
  68.     // Gomp hozzáatyása a navButtons div-hez
  69.     const navButtons = document.getElementById('navButtons');
  70.     if (navButtons) {
  71.         const blacklistButton = document.createElement('a');
  72.         blacklistButton.innerHTML = '<span style="color: red; font-size: 20px;">❌</span>';
  73.         blacklistButton.href = 'javascript:void(0);';
  74.         blacklistButton.title = 'Tiltólista kezelése';
  75.  
  76.         blacklistButton.addEventListener('click', () => {
  77.             createBlacklistButtons();
  78.             popup.style.display = 'block';
  79.         });
  80.  
  81.         navButtons.appendChild(blacklistButton);
  82.     } else {
  83.         console.error('Nem található a #navButtons elem!');
  84.     }
  85.  
  86.     // Tiltólista ajkajmazása
  87.     function applyBlacklist() {
  88.         $('.comment').each(function () {
  89.             const author = $(this).find('.verified').text().trim();
  90.             if (blacklist.includes(author)) {
  91.                 $(this).remove();
  92.             }
  93.         });
  94.     }
  95.  
  96.     // Tijtás gomp hozzáatyása a hozzászójásokhoz
  97.     function addBlacklistButton(comment) {
  98.         const authorSpan = $(comment).find('.verified');
  99.         if (!authorSpan.length || authorSpan.prev().hasClass('blacklist-button')) return;
  100.  
  101.         const author = authorSpan.text().trim();
  102.         const blacklistButton = $('<span>', {
  103.             class: 'blacklist-button',
  104.             html: '<span style="color: red; font-size: 15px; cursor: pointer; margin-right: 5px;">❌</span>',
  105.             click: () => {
  106.                 if (!blacklist.includes(author)) {
  107.                     blacklist.push(author);
  108.                     GM.setValue('blacklist', blacklist);
  109.                     applyBlacklist();
  110.                 }
  111.             }
  112.         });
  113.  
  114.         authorSpan.before(blacklistButton);
  115.     }
  116.  
  117.     // Új hozzászójások fityelése
  118.     let observeNewComments = false;
  119.     const newCommentsDiv = document.querySelector('.newComments');
  120.  
  121.     if (newCommentsDiv) {
  122.         newCommentsDiv.addEventListener('click', () => {
  123.             observeNewComments = true;
  124.         });
  125.     }
  126.  
  127.     const observer = new MutationObserver(mutations => {
  128.         if (!observeNewComments) return;
  129.  
  130.         mutations.forEach(mutation => {
  131.             if (mutation.type === 'childList') {
  132.                 mutation.addedNodes.forEach(node => {
  133.                     if ($(node).is('.comment') && !$(node).hasClass('blacklist-button-added')) {
  134.                         addBlacklistButton(node);
  135.                     }
  136.                 });
  137.             }
  138.         });
  139.  
  140.         applyBlacklist();
  141.     });
  142.     observer.observe(document.body, { childList: true, subtree: true });
  143.  
  144.     // Blacklist gompok jétjehozása és hozzáatyása a fejugjó aplakhoz
  145.     function createBlacklistButtons() {
  146.         userList.innerHTML = '';
  147.  
  148.         blacklist.forEach(user => {
  149.             const button = document.createElement('button');
  150.             button.textContent = user;
  151.             button.style.padding = '8px 12px';
  152.             button.style.backgroundColor = '#f4f4f4';
  153.             button.style.border = 'none';
  154.             button.style.borderRadius = '4px';
  155.             button.style.cursor = 'pointer';
  156.             button.style.transition = 'background-color 0.3s';
  157.  
  158.             const removeButton = document.createElement('span');
  159.             removeButton.textContent = '✕';
  160.             removeButton.style.marginLeft = '8px';
  161.             removeButton.style.color = '#666';
  162.             removeButton.style.cursor = 'pointer';
  163.  
  164.             removeButton.addEventListener('click', (e) => {
  165.                 e.stopPropagation();
  166.                 blacklist = blacklist.filter(name => name !== user);
  167.                 GM.setValue('blacklist', blacklist);
  168.                 createBlacklistButtons();
  169.                 applyBlacklist();
  170.             });
  171.  
  172.             button.addEventListener('click', () => {
  173.                 button.style.backgroundColor = '#e0e0e0';
  174.             });
  175.  
  176.             button.addEventListener('mouseleave', () => {
  177.                 button.style.backgroundColor = '#f4f4f4';
  178.             });
  179.  
  180.             button.appendChild(removeButton);
  181.             userList.appendChild(button);
  182.         });
  183.     }
  184.  
  185.     applyBlacklist();
  186.     $('.comment').each(function () { addBlacklistButton(this); });
  187.     createBlacklistButtons();
  188. })(jQuery);
  189.  
  190. // Szejelmes vagyok a kibaszott Tibibe!
  191.  
Advertisement
Add Comment
Please, Sign In to add comment