AntiRickRoll

Blocks rickroll videos on YT

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         AntiRickRoll
// @version      1.2
// @description  Blocks rickroll videos on YT
// @author       stijnb1234
// @license      GNU GPLv3; https://choosealicense.com/licenses/gpl-3.0/
// @match        *://www.youtube.com/watch?v=iik25wqIuFo*
// @match        *://www.youtube.com/watch?v=oHg5SJYRHA0*
// @match        *://www.youtube.com/watch?v=dQw4w9WgXcQ*
// @match        *://www.youtube.com/watch?v=xvFZjo5PgG0*
// @match        *://www.youtube.com/watch?v=ERdv8aKaDiU*
// @match        *://www.youtube.com/watch?v=ZXpThNX9IRc*
// @grant        none
// @run-at       document-start
// @namespace    https://greasyfork.org/users/1307578
// ==/UserScript==

(function() {
    'use strict';

    // Function to block video before it starts playing
    function blockVideoBeforeStart() {
        var loadCheckInterval = setInterval(function() {
            var video = document.querySelector('video');
            if (video && video.readyState === 4) {
                clearInterval(loadCheckInterval);
                // Remove the video container and its parent
                var videoContainer = document.querySelector('.html5-video-container');
                if (videoContainer && videoContainer.parentNode) {
                    videoContainer.parentNode.removeChild(videoContainer);
                    if (videoContainer.parentNode.parentNode) {
                        videoContainer.parentNode.parentNode.removeChild(videoContainer.parentNode);
                    }
                }
                // Mute the audio associated with the video
                var audio = document.querySelector('audio');
                if (audio) {
                    audio.muted = true;
                }
            }
        }, 100);
    }

    blockVideoBeforeStart();

    // Function to display message after a delay
    function displayMessage() {
        // Hide page after delay
        setTimeout(function() {
            document.body.innerHTML = '';
        }, 250);
        // Show a custom message on the page after delay
        setTimeout(function() {
            alert('RICKROLL BLOCKED\nDisable this script to continue');
        }, 500);
    }

    displayMessage();
})();