mirror of
https://github.com/FlamedDogo99/EaglerMobile.git
synced 2024-11-24 04:56:04 -08:00
Update eaglermobile.user.js
This commit is contained in:
parent
0bda17325d
commit
243664634a
|
@ -6,7 +6,7 @@
|
||||||
// @downloadURL https://raw.githubusercontent.com/FlamedDogo99/EaglerMobile/main/eaglermobile.user.js
|
// @downloadURL https://raw.githubusercontent.com/FlamedDogo99/EaglerMobile/main/eaglermobile.user.js
|
||||||
// @license Apache License 2.0 - http://www.apache.org/licenses/
|
// @license Apache License 2.0 - http://www.apache.org/licenses/
|
||||||
// @match https://eaglercraft.com/mc/*
|
// @match https://eaglercraft.com/mc/*
|
||||||
// @version 3.0.2
|
// @version 3.0.3-alpha-1
|
||||||
// @updateURL https://raw.githubusercontent.com/FlamedDogo99/EaglerMobile/main/eaglermobile.user.js
|
// @updateURL https://raw.githubusercontent.com/FlamedDogo99/EaglerMobile/main/eaglermobile.user.js
|
||||||
// @run-at document-start
|
// @run-at document-start
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
@ -54,8 +54,8 @@ Object.defineProperty(EventTarget.prototype, "addEventListener", {
|
||||||
});
|
});
|
||||||
// Allows typing in #hiddenInput
|
// Allows typing in #hiddenInput
|
||||||
const _preventDefault = Event.prototype.preventDefault;
|
const _preventDefault = Event.prototype.preventDefault;
|
||||||
Event.prototype.preventDefault = function() {
|
Event.prototype.preventDefault = function(shouldBypass) {
|
||||||
if(document.activeElement.id != "hiddenInput") {
|
if(document.activeElement.id != "hiddenInput" || shouldBypass) {
|
||||||
this._preventDefault = _preventDefault;
|
this._preventDefault = _preventDefault;
|
||||||
this._preventDefault();
|
this._preventDefault();
|
||||||
}
|
}
|
||||||
|
@ -367,11 +367,13 @@ function insertCanvasElements() {
|
||||||
hiddenInput.style.cssText = "position:absolute;top: 0vh; margin: auto; left: 8vh; right:0vh; width: 8vh; height: 8vh;font-size:20px;z-index:-10;color: transparent;text-shadow: 0 0 0 black;";
|
hiddenInput.style.cssText = "position:absolute;top: 0vh; margin: auto; left: 8vh; right:0vh; width: 8vh; height: 8vh;font-size:20px;z-index:-10;color: transparent;text-shadow: 0 0 0 black;";
|
||||||
hiddenInput.value = " " //Allows delete to be detected before input is changed
|
hiddenInput.value = " " //Allows delete to be detected before input is changed
|
||||||
hiddenInput.addEventListener("input", function(e) {
|
hiddenInput.addEventListener("input", function(e) {
|
||||||
let inputData = e.data ?? "delete"; // backspace makes null
|
e.preventDefault(true);
|
||||||
|
let inputData = e.data == null ? "delete" : e.data.slice(-1); // backspace makes null
|
||||||
window.lastKey = inputData
|
window.lastKey = inputData
|
||||||
hiddenInput.value = " "; // We need a character to detect deleting
|
hiddenInput.value = " "; // We need a character to detect deleting
|
||||||
if(window.keyboardFix) {
|
if(window.keyboardFix) {
|
||||||
if(e.inputType == 'insertText') {
|
const sliceInputType = e.inputType.slice(0,1); // This is a really dumb way to do this because it's not future-proof
|
||||||
|
if(sliceInputType== 'i') {
|
||||||
let isShift = (inputData.toLowerCase() != inputData);
|
let isShift = (inputData.toLowerCase() != inputData);
|
||||||
if(isShift) {
|
if(isShift) {
|
||||||
keyEvent("shift", "keydown")
|
keyEvent("shift", "keydown")
|
||||||
|
@ -382,9 +384,9 @@ function insertCanvasElements() {
|
||||||
keyEvent(inputData, "keydown");
|
keyEvent(inputData, "keydown");
|
||||||
keyEvent(inputData, "keyup");
|
keyEvent(inputData, "keyup");
|
||||||
}
|
}
|
||||||
} else if (e.inputType == 'deleteContentForward' || e.inputType == 'deleteContentBackward') {
|
} else if (sliceInputType == 'd') {
|
||||||
keyEvent("backspace", "keydown")
|
keyEvent("backspace", "keydown");
|
||||||
keyEvent("backspace", "keyup")
|
keyEvent("backspace", "keyup");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
@ -393,8 +395,8 @@ function insertCanvasElements() {
|
||||||
console.warn("Switching from keydown to input events due to invalid KeyboardEvent. Some functionality will be lost.")
|
console.warn("Switching from keydown to input events due to invalid KeyboardEvent. Some functionality will be lost.")
|
||||||
window.keyboardFix = true;
|
window.keyboardFix = true;
|
||||||
if(window.lastKey) {
|
if(window.lastKey) {
|
||||||
keyEvent(window.lastKey, "keydown")
|
keyEvent(window.lastKey, "keydown");
|
||||||
keyEvent(window.lastKey, "keyup")
|
keyEvent(window.lastKey, "keyup");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, false);
|
}, false);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user