Syncon

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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