TokyoMotion Downloader

Fetch videos and photos from tokyomotion HD quality when available

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği yüklemek için Tampermonkey gibi bir uzantı yüklemeniz gerekir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

Bu stili yüklemek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için Stylus gibi bir uzantı kurmanız gerekir.

Bu stili yükleyebilmek için Stylus gibi bir uzantı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

Bu stili yüklemek için bir kullanıcı stili yöneticisi uzantısı kurmanız gerekir.

Bu stili yükleyebilmek için bir kullanıcı stili yöneticisi uzantısı yüklemeniz gerekir.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         TokyoMotion Downloader
// @namespace    https://github.com/TohoEnjoyer2000/TokyoMotion-crx
// @name:ja           TokyoMotion Downloader
// @description:ja    Fetch videos and photos from tokyomotion HD quality when available
// @version      1.0.3
// @description  Fetch videos and photos from tokyomotion HD quality when available
// @match        https://www.tokyomotion.net/video/*
// @match        https://www.osakamotion.net/video/*
// @grant        none
// @run-at       document-end
// @license MIT 
// ==/UserScript==

(function () {
    'use strict';

    function run() {
        const referer = window.location.href;
        const id = referer.split('/')[4] ?? 'video';
        const titleElem = document.getElementsByClassName(
            'hidden-xs big-title-truncate m-t-0'
        )[0];

        if (!titleElem) return;

        const title = titleElem.innerText.replace(/[\\/:*?"<>|]/g, '_');

        const sep = document.getElementsByClassName(
            'separator m-t-15 p-0'
        )[0];
        if (!sep) return;

        const video = document.getElementsByTagName('video')[0];
        if (!video) return;

        const sources = Array.from(video.childNodes)
            .filter(n => n.nodeName.toLowerCase() === 'source')
            .map(s => s.src);

        if (sources.length === 0) return;

        const srcSD = sources[0];
        const srcHD = sources[1];
        const src = srcHD ?? srcSD;

        const curl = `curl -e "${referer}" "${src}" -L -o "${title}.mp4"`;
        const aria = `aria2c --referer="${referer}" "${src}"`;

        const box = document.createElement('div');
        box.style =
            'background-color:#f2f2f2;color:#000;border-radius:0.5rem;border:1px solid #9c9c9c;padding:4px;margin-bottom:6px;';

        const pre = document.createElement('pre');
        pre.textContent = `${curl}\n\n${aria}`;
        pre.style = 'white-space:pre-wrap;border:0;background:#f2f2f2;';

        const btn = document.createElement('a');
        btn.textContent = 'Download';
        btn.href = src;
        btn.download = `${id}.mp4`;
        btn.target = '_blank';
        btn.className = 'btn btn-primary navbar-btn';
        btn.onclick = () => {
            window.open(src, 'download_window');
            return false;
        };

        box.appendChild(pre);
        sep.appendChild(box);
        sep.appendChild(btn);
    }

    window.addEventListener('load', run);
})();