Skocz do miejsca

Dodaje linki do konkretnych miejsc w wideo w serwisie wykop.pl

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Skocz do miejsca
// @namespace    http://tampermonkey.net/
// @version      0.1
// @author       henk
// @match        https://www.wykop.pl/link/*
// @grant        none
// @description     Dodaje linki do konkretnych miejsc w wideo w serwisie wykop.pl
// ==/UserScript==

function addIcon() {

    var tregex = /(\d(:|\.))*([0-5][0-9]|[0-9])(:|\.)[0-5][0-9]/gi;
    var lregex = /http(?:s?):\/\/(?:www\.)?youtu(?:be\.com\/watch\?v=|\.be\/)([\w\-\_]*)/gi;

    url = document.querySelector('[title="Otwórz źródło znaleziska"]').href;

    ytLink = url.match(lregex);

    for (i = 0; i < document.querySelectorAll(".text").length; i++) {

        comment = document.querySelectorAll(".text")[i].innerHTML;
        results = comment.match(tregex);


        if (results != null) {
            for (j = 0; j < results.length; j++) {
                timeelements = results[j].split(/:|\./).reverse();
                timestamp = 0;
                for (k = 0; k < timeelements.length; k++) {
                    timestamp = timestamp + Math.pow(60, k) * timeelements[k];
                }

                comment = comment.replace(results[j], results[j] + " " + '<a href="' + ytLink + '&t=' + timestamp + '&autoplay=1">\u25B6</a>');

            }
            document.getElementsByClassName("text")[i].innerHTML = comment;
        }

    }

}

document.onload = addIcon();