-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
57 lines (54 loc) · 1.99 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const EVENT_OPTIONS = {bubbles: true, cancelable: false, composed: true};
const EVENTS = {
BLUR: new Event("blur", EVENT_OPTIONS),
CHANGE: new Event("change", EVENT_OPTIONS),
INPUT: new Event("input", EVENT_OPTIONS),
};
function overrideListeners(eventType) {
window.addEventListener(eventType, function(event) {
event.stopImmediatePropagation();
}, true);
}
var inputDiv = document.createElement("div"),
inputText = document.createElement("textarea"),
inputButton = document.createElement("button");
try {
console.log("TRY BLOCK START");
overrideListeners("cut");
overrideListeners("copy");
overrideListeners("paste");
var ACE_SCROLLER = document.getElementsByClassName("ace_scroller")[0];
console.log(ACE_SCROLLER);
if (ACE_SCROLLER != undefined) {
console.log("ACE_SCROLLER PASSED");
document.getElementsByTagName("body")[0].appendChild(inputDiv);
inputDiv.appendChild(inputText);
inputDiv.appendChild(inputButton);
inputButton.textContent = "⤶";
inputButton.style.color = "#fff";
inputButton.style.background = "#000";
inputText.style.color = "#fff";
inputText.style.background = "#000";
inputDiv.style.position = "absolute";
inputDiv.style.top = "60px";
inputDiv.style.left = "0px";
inputDiv.style.zIndex = "2147483647";
document.getElementsByClassName("ace_scroller")[0].addEventListener("click", (event) => {
var inputElement = document.getElementById("ace_text-input-textarea");
inputText.value = inputElement.value;
});
inputButton.addEventListener("click", (event) => {
var text = inputText.value ;
var inputElement = document.getElementById("ace_text-input-textarea");
inputElement.value = text;
var tracker = inputElement._valueTracker
tracker && tracker.setValue(text);
inputElement.dispatchEvent(EVENTS.INPUT);
inputElement.dispatchEvent(EVENTS.BLUR);
});
} else {
console.log("ACE_SCROLLER UNDEFINED");
}
} catch {
console.log("TRY FAILED");
}