Watch on Invidious/Piped

Scroll to open videos on Invidious;

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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        Watch on Invidious/Piped
// @homepageURL https://gitlab.com/menguele/watch-on-invidious
// @namespace   Violentmonkey Scripts
// @grant       none
// @version     0.1
// @author      menguele
// @license GPL-3.0-or-later; http://www.gnu.org/licenses/gpl-3.0.txt
// @description Scroll to open videos on Invidious;
// @match *://*.youtube.com/*
// @run-at document-end
// ==/UserScript==
InvidiousInstance = 'https://vid.puffyan.us/';//Change this to your preffered instance
middleClickRedirect = true;//True redirects only on middle click, false redirects only on left click

window.addEventListener("scroll", hijackLinks); //Only activates the script after a mouse wheel scroll

function hijackLinks() {
    document.querySelectorAll("a#thumbnail:not(.hijacked)").forEach(x => {
        x.classList.add("hijacked"); // Fix typo here (changed "hikacked" to "hijacked")
        x.style.border = "2px solid magenta";
        middleClickRedirect ? x.addEventListener("auxclick", openVideo):x.addEventListener("click", openVideo);
    });
}

function openVideo(e) {
    e.preventDefault();
    e.stopPropagation();
    let link = InvidiousInstance + this.getAttribute("href");
    //console.log("opening", link);
    middleClickRedirect ? window.open(link,"_blank").blur():window.open(link);
}