[JS] 드래그 방지 해제
아래 내용을 디버그툴 콘솔에 붙여넣기 --> 끝
(function () {
if (window.subvaAllowRightClick === undefined) {
// https://greasyfork.org/en/scripts/23772-absolute-enable-right-click-copy/code
window.subvaAllowRightClick = function (dom) {
(function GetSelection() {
var Style = dom.createElement('style');
Style.type = 'text/css';
var TextNode = '*{user-select:text!important;-webkit-user-select:text!important;}';
if (Style.styleSheet) {
Style.styleSheet.cssText = TextNode;
}
else {
Style.appendChild(dom.createTextNode(TextNode));
}
dom.getElementsByTagName('head')[0].appendChild(Style);
})();
(function SetEvents() {
var events = ['copy', 'cut', 'paste', 'select', 'selectstart'];
for (var i = 0; i < events.length; i++)
dom.addEventListener(events[i], function (e) {
e.stopPropagation();
}, true);
})();
(function RestoreEvents() {
var n = null;
var d = document;
var b = dom.body;
var SetEvents = [d.oncontextmenu = n, d.onselectstart = n, d.ondragstart = n, d.onmousedown = n];
var GetEvents = [b.oncontextmenu = n, b.onselectstart = n, b.ondragstart = n, b.onmousedown = n, b.oncut = n, b.oncopy = n, b.onpaste = n];
})();
(function RightClickButton() {
setTimeout(function () {
dom.oncontextmenu = null;
}, 2000);
function EventsCall(callback) {
this.events = ['DOMAttrModified', 'DOMNodeInserted', 'DOMNodeRemoved', 'DOMCharacterDataModified', 'DOMSubtreeModified'];
this.bind();
}
EventsCall.prototype.bind = function () {
this.events.forEach(function (event) {
dom.addEventListener(event, this, true);
}.bind(this));
};
EventsCall.prototype.handleEvent = function () {
this.isCalled = true;
};
EventsCall.prototype.unbind = function () {
this.events.forEach(function (event) {
}.bind(this));
};
function EventHandler(event) {
this.event = event;
this.contextmenuEvent = this.createEvent(this.event.type);
}
EventHandler.prototype.createEvent = function (type) {
var target = this.event.target;
var event = target.ownerDocument.createEvent('MouseEvents');
event.initMouseEvent(type, this.event.bubbles, this.event.cancelable,
target.ownerDocument.defaultView, this.event.detail,
this.event.screenX, this.event.screenY, this.event.clientX, this.event.clientY,
this.event.ctrlKey, this.event.altKey, this.event.shiftKey, this.event.metaKey,
this.event.button, this.event.relatedTarget);
return event;
};
EventHandler.prototype.fire = function () {
var target = this.event.target;
var contextmenuHandler = function (event) {
event.preventDefault();
}.bind(this);
target.dispatchEvent(this.contextmenuEvent);
this.isCanceled = this.contextmenuEvent.defaultPrevented;
};
window.addEventListener('contextmenu', handleEvent, true);
function handleEvent(event) {
event.stopPropagation();
event.stopImmediatePropagation();
var handler = new EventHandler(event);
window.removeEventListener(event.type, handleEvent, true);
var EventsCallBback = new EventsCall(function () {
});
handler.fire();
window.addEventListener(event.type, handleEvent, true);
if (handler.isCanceled && (EventsCallBback.isCalled))
event.preventDefault();
}
})();
// function KeyPress(e) {
// if (e.altKey && e.ctrlKey) {
// if (confirm("Activate Absolute Right Click Mode!") === true) {
// Absolute_Mod();
// }
// }
// }
// dom.addEventListener("keydown", KeyPress);
(function Absolute_Mod() {
var events = ['contextmenu', 'copy', 'cut', 'paste', 'mouseup', 'mousedown', 'keyup', 'keydown', 'drag', 'dragstart', 'select', 'selectstart'];
for (var i = 0; i < events.length; i++) {
dom.addEventListener(events[i], function (e) {
e.stopPropagation();
}, true);
}
})();
};
// window.subvaAllowRightClick(document);
function runAll(w) {
try {
window.subvaAllowRightClick(w.document);
} catch (e) {
}
for (var i = 0; i < w.frames.length; i++) {
runAll(w.frames[i]);
}
}
}
runAll(window);
})();
'프로그램... > 프로...WEB' 카테고리의 다른 글
[JS] 융용한 코드 모음 (0) | 2019.04.03 |
---|---|
[CSS] Layer (0) | 2019.02.26 |
[PHP] 유용한 Utils (0) | 2019.02.26 |
[JS] target to IFRAME (0) | 2019.02.26 |
[CSS] 기본 (0) | 2018.12.19 |