DropStop

Cancel drop event so page doesn't navigate away

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        DropStop
// @author      Jefferson "jscher2000" Scher
// @namespace   JeffersonScher
// @version     1
// @description Cancel drop event so page doesn't navigate away
// @copyright   Copyright 2015 Jefferson Scher
// @license     BSD
// @include     *
// @grant       none
// ==/UserScript==

function IgnoreDrop(evt){
  // allow drop for inputs and textareas
  if (evt.target.nodeName == "INPUT" || evt.target.nodeName == "TEXTAREA") return;
  // allow drop for contenteditable elements
  if (evt.target.getAttribute("contenteditable") == "true") return;
  // prevent default action and kill the event
  evt.preventDefault();
  evt.stopPropagation();
  return false;
}
document.body.addEventListener("drop", IgnoreDrop, true);
// Per https://opensourcehacker.com/2011/11/11/cancelling-html5-drag-and-drop-events-in-web-browsers/
document.body.addEventListener("dragover", IgnoreDrop, true);
document.body.addEventListener("dragenter", IgnoreDrop, true);