Fix NUDE Playground Comment Paste

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

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