Fix NUDE Playground Comment Paste

Fixes the issue where pasting text into comment fields is blocked on nudeplayground.com.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         Fix NUDE Playground Comment Paste
// @name:ru      Fix NUDE Playground Comment Paste
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Fixes the issue where pasting text into comment fields is blocked on nudeplayground.com.
// @description:ru Исправляет проблему с блокировкой вставки текста в поля комментариев на nudeplayground.com.
// @author       DenParabal
// @match        https://nudeplayground.com/*
// @grant        none
// @run-at       document-start
// @license      MIT
// ==/UserScript==


(function() {
    'use strict';

    window.addEventListener('paste', function(event) {
        const target = document.activeElement;

        if (target && (target.classList.contains('commentBox') || target.classList.contains('post-area-input'))) {
            const items = event.clipboardData && event.clipboardData.items;
            let hasImage = false;

            if (items) {
                for (let i = 0; i < items.length; i++) {
                    if (items[i].type.indexOf('image') !== -1) {
                        hasImage = true;
                        break;
                    }
                }
            }

            // If no image is detected, block the site's listener from stopping the paste event.
            // This allows the browser to execute the default text paste behavior.
            if (!hasImage) {
                event.stopImmediatePropagation();
            }
        }
    }, true);
})();