Guest User

Untitled

a guest
Sep 24th, 2026
967
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Stary Vikop
  3. // @author       Nogisz
  4. // @namespace    https://wykop.pl/
  5. // @version      2026-09-24
  6. // @description  Wyłącz nowe "drzewko komentarzy" w pizdu
  7. // @match        https://wykop.pl/*
  8. // @icon         https://www.google.com/s2/favicons?sz=64&domain=wykop.pl
  9. // @grant        none
  10. // @run-at       document-start
  11. // ==/UserScript==
  12.  
  13. (function () {
  14.     'use strict';
  15.  
  16.     const STORAGE_KEY = 'wykop-comments-tree-enabled';
  17.     const INPUT_ID = 'tampermonkey-comments-tree';
  18.  
  19.     function getStore() {
  20.         return [...document.querySelectorAll('*')]
  21.             .map(el => el.__vue__)
  22.             .find(vm => vm?.$store)
  23.             ?.$store;
  24.     }
  25.  
  26.     function getEnabled() {
  27.         const value = localStorage.getItem(STORAGE_KEY);
  28.         return value === null ? false : value === 'true';
  29.     }
  30.  
  31.     function setEnabled(enabled) {
  32.         localStorage.setItem(STORAGE_KEY, String(enabled));
  33.  
  34.         const store = getStore();
  35.  
  36.         if (!store) {
  37.             return false;
  38.         }
  39.  
  40.         store.commit('config/setCommentsTreeEnabled', enabled);
  41.  
  42.         console.log(
  43.             '[Stary Vikop]',
  44.             enabled ? 'Drzewko włączone!' : 'Drzewko wyłączone!'
  45.         );
  46.  
  47.         return true;
  48.     }
  49.  
  50.     function applySetting() {
  51.         const enabled = getEnabled();
  52.  
  53.         if (setEnabled(enabled)) {
  54.             return;
  55.         }
  56.  
  57.         const interval = setInterval(() => {
  58.             if (setEnabled(enabled)) {
  59.                 clearInterval(interval);
  60.             }
  61.         }, 20);
  62.  
  63.         setTimeout(() => clearInterval(interval), 10000);
  64.     }
  65.  
  66.     function injectSetting() {
  67.         if (location.pathname !== '/ustawienia/ogolne') {
  68.             return;
  69.         }
  70.  
  71.         if (document.getElementById(INPUT_ID)) {
  72.             return;
  73.         }
  74.  
  75.         const section = document.querySelector('section.display');
  76.  
  77.         if (!section) {
  78.             return;
  79.         }
  80.  
  81.         const form = section.querySelector('form');
  82.  
  83.         if (!form) {
  84.             return;
  85.         }
  86.  
  87.         const template = form.querySelector('.form-group .switch');
  88.  
  89.         if (!template) {
  90.             return;
  91.         }
  92.  
  93.         const templateFormGroup = template.closest('.form-group');
  94.  
  95.         if (!templateFormGroup) {
  96.             return;
  97.         }
  98.  
  99.         const formGroup = templateFormGroup.cloneNode(true);
  100.  
  101.         const input = formGroup.querySelector('input[type="checkbox"]');
  102.         const label = formGroup.querySelector('label');
  103.         const text = formGroup.querySelector('label span');
  104.  
  105.         if (!input || !label || !text) {
  106.             return;
  107.         }
  108.  
  109.         input.id = INPUT_ID;
  110.         input.checked = getEnabled();
  111.  
  112.         label.setAttribute('for', INPUT_ID);
  113.  
  114.         text.textContent = 'Wyświetlaj Mikroblog w formie drzewa';
  115.  
  116.         input.addEventListener('change', () => {
  117.             setEnabled(input.checked);
  118.         });
  119.  
  120.         const confirm = form.querySelector('.confirm');
  121.  
  122.         if (confirm) {
  123.             form.insertBefore(formGroup, confirm);
  124.         } else {
  125.             form.appendChild(formGroup);
  126.         }
  127.     }
  128.  
  129.     applySetting();
  130.  
  131.     const observer = new MutationObserver(() => {
  132.         injectSetting();
  133.     });
  134.  
  135.     observer.observe(document.documentElement, {
  136.         childList: true,
  137.         subtree: true
  138.     });
  139.  
  140.     if (document.readyState === 'loading') {
  141.         document.addEventListener('DOMContentLoaded', injectSetting);
  142.     } else {
  143.         injectSetting();
  144.     }
  145. })();
Advertisement
Add Comment
Please, Sign In to add comment