Syncon

더블콘이 동시에 재생될 수 있게 전부 불러온 뒤 화면에 보여지게 변경합니다

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

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 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.

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

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!)

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.

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

// ==UserScript==
// @name        Syncon
// @namespace   syncon
// @description 더블콘이 동시에 재생될 수 있게 전부 불러온 뒤 화면에 보여지게 변경합니다
// @version     0.1.0
// @author      Sangha Lee
// @copyright   2024, Sangha Lee
// @license     MIT
// @match       https://gall.dcinside.com/board/view/*
// @match       https://gall.dcinside.com/mgallery/board/view/*
// @match       https://gall.dcinside.com/mini/board/view/*
// @match       https://gall.dcinside.com/person/board/view/*
// @icon        https://nstatic.dcinside.com/dc/m/img/dcinside_icon.png
// ==/UserScript==


/**
 * @param {T[]} array 
 * @param {number} n
 * @returns {T[][]} 
 */
function* chunks (array, n) {
    for (let i = 0; i < array.length; i += n) {
        yield array.slice(i, i + n)
    }
}

function sync () {
    for (const $chunk of [
        ...chunks([...document.querySelectorAll('.comment_dccon.double video')], 2)
    ]) {
        const promises = $chunk.map(
            /** @returns {Promise<HTMLImageElement>} */
            $video => new Promise((resolve, reject) => {
                // fuck off autoplay permission, we fully gifing
                const $img = document.createElement('img')
                $img.classList.add('written_dccon')
                $img.src = $video.getAttribute('onmousedown').split("'")[1]

                if ($video.classList.contains('bigdccon')) {
                    $img.classList.add('bigdccon')   
                }

                $img.addEventListener('load', () => resolve($img))
                $img.addEventListener('error', reject)

                $video.insertAdjacentElement('beforebegin', $img)
                $video.remove()
            })
        )

        Promise.all(promises)
            .then($imgs => $imgs.forEach($img => {
                const src = $img.src
                $img.src = 'data:image/gif;base64,R0lGODlhAQABAAAAACw='
                setTimeout(() => $img.src = src, 100)
            }))
    }
}

new MutationObserver(sync)
    .observe(document.querySelector('.comment_wrap'), {
        childList: true
    })

sync()