Last ditch-effort

If this doesn’t work on android, I don’t know what will
This commit is contained in:
FlamedDogo99 2024-06-05 21:04:01 -06:00 committed by GitHub
parent 9ae89de928
commit 0badfd6f8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 2.6 // @version 2.7
// @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==
@ -30,47 +30,25 @@ window.sprintLock = false;
var previousTouchX = null; var previousTouchX = null;
var previousTouchY = null; var previousTouchY = null;
var startTouchX = null; var startTouchX = null;
// Polyfill for apply // Ignores keydown events that don't have the isValid parameter set to true
Function.prototype.polyfillApply = function(currentContext = {}, arg = []) { var _addEventListener = EventTarget.prototype.addEventListener;
if (typeof this !== 'function') { EventTarget.prototype.addEventListener = function(type, fn, capture) {
throw new Error(this + "it's not callable"); this._addEventListener = _addEventListener;
} this._addEventListener(type, function(...args) {
if (!Array.isArray(arg)) {
throw new TypeError('CreateListFromArrayLike called on non-object')
}
currentContext.fn = this;
currentContext.fn(...arg);
}
// Polyfill for call
Function.prototype.polyfillCall = function(currentContext = {}, ...arg) {
if (typeof this !== 'function') {
throw new Error(this + "it's not callable");
}
currentContext.fn = this;
currentContext.fn(...arg);
}
// Ignores any keydown event that doesn't have the isValid parameter.
const _addEventListener = EventTarget.prototype.addEventListener;
Object.defineProperty(EventTarget.prototype, "addEventListener", {
value: function (type, fn, ...rest) {
_addEventListener.call(this, type, function(...args) {
if(type === 'keydown' && (!args[0].isValid)) { if(type === 'keydown' && (!args[0].isValid)) {
return; return;
} }
return fn.polyfillApply(this, args); return fn(...args);
}, ...rest); }, capture);
} }
});
// Allows typing in #hiddenInput // Allows typing in #hiddenInput
const _preventDefault = Event.prototype.preventDefault; const _preventDefault = Event.prototype.preventDefault;
Object.defineProperty(Event.prototype, "preventDefault", { Event.prototype.preventDefault = function() {
value: function () { if(document.activeElement.id != "hiddenInput") {
if(document.activeElement.id != "hiddenInput") { this._preventDefault = _preventDefault;
_preventDefault.polyfillCall(this); this._preventDefault();
} }
} }
});
// Key and mouse events // Key and mouse events
function keyEvent(name, state) { function keyEvent(name, state) {
const keyName = name.toUpperCase().charCodeAt(0); const keyName = name.toUpperCase().charCodeAt(0);