Advertisement
Guest User

ytadskip

a guest
Jun 8th, 2025
6
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 3.06 KB | Source Code | 0 0
  1. // ==UserScript==
  2. // @name         AdBlockThisYT2
  3. // @namespace    SebaARG22
  4. // @version      3.0.2
  5. // @description  Permite reproducir videos con AdBlock activado sin errores ni bloqueos, incluso en nueva pestaña. Reanuda video si está en pausa después de quitar overlays.
  6. // @author       SebaARG22
  7. // @match        *://www.youtube.com/*
  8. // @icon         https://i.imgur.com/fd1D46S.png
  9. // @run-at       document-start
  10. // @license      MIT
  11. // @grant        none
  12. // ==/UserScript==
  13.  
  14. (function () {
  15.     'use strict';
  16.  
  17.     const LOG_PREFIX = '[😭 CryTubeFix]';
  18.  
  19.     console.log(`${LOG_PREFIX} Script iniciado. Bloqueando el berrinche de YouTube.`);
  20.  
  21.     // 1. Oculta overlays molestos
  22.     const css = `
  23.         ytd-enforcement-message-view-model,
  24.         tp-yt-paper-dialog,
  25.         ytd-popup-container,
  26.         #dialog,
  27.         .ytp-ad-overlay-container,
  28.         .ytp-ad-player-overlay,
  29.         .ytp-ad-module {
  30.             display: none !important;
  31.             opacity: 0 !important;
  32.             visibility: hidden !important;
  33.         }
  34.         body {
  35.             overflow: auto !important;
  36.         }
  37.     `;
  38.     const style = document.createElement('style');
  39.     style.textContent = css;
  40.     document.documentElement.appendChild(style);
  41.  
  42.     console.log(`${LOG_PREFIX} CSS inyectado. Publicidad visual: OUT.`);
  43.  
  44.     // 2. Observa cambios en el DOM para eliminar bloqueos dinámicos y reanudar video
  45.     const observer = new MutationObserver(() => {
  46.         const dialogs = document.querySelectorAll('ytd-popup-container tp-yt-paper-dialog, ytd-enforcement-message-view-model');
  47.         dialogs.forEach(el => {
  48.             console.log(`${LOG_PREFIX} Eliminado un popup llorón.`);
  49.             el.remove();
  50.         });
  51.  
  52.         const backdrop = document.querySelector('#backdrop');
  53.         if (backdrop) {
  54.             console.log(`${LOG_PREFIX} Backdrop eliminado.`);
  55.             backdrop.remove();
  56.         }
  57.  
  58.         document.body.style.overflow = 'auto';
  59.  
  60.         // Intenta reanudar el video si está en pausa
  61.         const video = document.querySelector('video');
  62.         if (video && video.paused) {
  63.             video.play().then(() => {
  64.                 console.log(`${LOG_PREFIX} Video reanudado automáticamente.`);
  65.             }).catch(err => {
  66.                 console.warn(`${LOG_PREFIX} No se pudo reanudar el video:`, err);
  67.             });
  68.         }
  69.     });
  70.     observer.observe(document, { childList: true, subtree: true });
  71.  
  72.     console.log(`${LOG_PREFIX} Observador activado. Listo para limpiar rabietas.`);
  73.  
  74.     // 3. Soluciona carga de video en nueva pestaña
  75.     if (window.location.pathname.startsWith('/watch')) {
  76.         window.addEventListener('DOMContentLoaded', () => {
  77.             const player = document.querySelector('video');
  78.             if (!player) {
  79.                 console.warn(`${LOG_PREFIX} Player no cargado. Reintentando...`);
  80.                 location.href = location.href;
  81.             } else {
  82.                 console.log(`${LOG_PREFIX} Video cargado correctamente.`);
  83.             }
  84.         });
  85.     }
  86.  
  87. })();
  88.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement