Syncon

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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