Prevent Paste Hijacking

Prevents websites from hijacking paste events and forces native text insertion. Hides paste event from the website.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Prevent Paste Hijacking
// @namespace   Violentmonkey Scripts
// @match       *://*/*
// @grant       none
// @version     1.1
// @description Prevents websites from hijacking paste events and forces native text insertion. Hides paste event from the website.
// @run-at      document-start
// @author      koza.dev
// @license     MIT
// ==/UserScript==



// Hide Ctrl+V keydown from the site unconditionally,
// since we cannot read the clipboard during a keydown event
window.addEventListener('keydown', function(e) {
    if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'v') {
        e.stopImmediatePropagation()
    }
}, true)

window.addEventListener('paste', function(e) {
    if (!e.clipboardData) return

    // If the clipboard contains files (like an image), abort the script
    // and let the website process the paste normally
    if (e.clipboardData.files.length > 0) return

    // If it's just text, hide the event from the website and force native paste
    e.stopImmediatePropagation()
}, true)