Skocz do miejsca

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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();