Greasy Fork

Greasy Fork is available in English.

vivo direct video source or video source to clipboard (for vlc playlist etc)

Wechselt automatisch zum vivo-Tab auf bs.to und auf vivo.XX kopiert es die Video-URL in den Zwischenspeicher oder leitet zur Videoquelle weiter

当前为 2021-07-20 提交的版本,查看 最新版本

// ==UserScript==
// @name           vivo direct video source or video source to clipboard (for vlc playlist etc)
// @author         xtrars
// @description    Wechselt automatisch zum vivo-Tab auf bs.to und auf vivo.XX kopiert es die Video-URL in den Zwischenspeicher oder leitet zur Videoquelle weiter
// @description:en Automatically switches to the vivo tab on bs.to and on vivo.XX it copies the video URL to the clipboard or redirects to the video source
// @include        https://bs.to/*
// @include        https://vivo.sx/*
// @include        https://vivo.st/*
// @version        1.0
// @run-at         document-start
// @license        CC BY 4.0
// @namespace http://greasyfork.icu/users/140785
// ==/UserScript==



(function() {
    'use strict';


    // CHANGE IF YOU WANT TO TRUE
    let bCloseTabAfterCopyToClipboard = false;


    // ADVANCED USERS ONLY
    window.addEventListener('load', function() {
        if (isVivo()) {
            // thanks to Wissidi dom (http://greasyfork.icu/de/scripts/28779-zu-vivo-video-navigieren/code)
            let src = document.getElementsByTagName('video')[document.getElementsByTagName('video').length -1]['currentSrc'];

            if (bCloseTabAfterCopyToClipboard) {
                navigator.clipboard.writeText(src);
                closeTab();
            } else {
                window['location'].replace(src);
            }
        }
    });

    if (isEpisode()) {
        document['location'].replace(document['location']['href'] + '/Vivo');
    }

    function isEpisode() {
        let vivoStr = '/Vivo';
        let isSerieRegex = /[0-9]{1,2}\/[0-9]{1,2}\-/g;

        return document['location']['href'].search(vivoStr) === -1 && document['location']['href'].search(isSerieRegex) !== -1;
    }

    function isVivo() {
        let regex = /vivo\..{1,3}\//g;
        return document['location']['href'].search(regex) && document.getElementsByTagName('video') && document.getElementsByTagName('video')[document.getElementsByTagName('video').length -1]
    }

    function closeTab() {
        setTimeout(function() {
            window.open("","_self").close();
        }, 500);
    }
})();