Skip to content

Instantly share code, notes, and snippets.

@NacimHarfouche
Created December 1, 2019 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NacimHarfouche/350f85fb548c3309ab465008835dcd94 to your computer and use it in GitHub Desktop.
Save NacimHarfouche/350f85fb548c3309ab465008835dcd94 to your computer and use it in GitHub Desktop.
refactoring of DC - MobileFixes (https://greasyfork.org/fr/scripts/392033-dc-mobilefixes )
// ==UserScript==
// @name DC - MobileFixes
// @namespace http://tampermonkey.net/
// @version 0.12
// @description Fix player interactions with draggable boxes
// @author Ajira
// @match https://www.dreadcast.net/Main
// @grant none
// ==/UserScript==
(() => {
'use strict';
/* TODO ==============================================
- Should loop on class identified objects like AITL
=================================================== */
// Stop event propagation
function disableEvent(event) {
event.stopPropagation();
}
// Trigger fix only if a dialogbox is popup
document.getElementById("zone_lightBox").addEventListener('DOMNodeInserted', () => {
// objet digi
var digi = {};
digi.input = document.getElementById("lb_textinput_digicode");
digi.form = digi.input.parentNode.parentNode;
digi.box = digi.form.parentNode.parentNode;
// Check if the dialogbox contains a digicode input
if (digi.input === null) return;
// Search the parent form of the digicode
if (digi.form === null) return;
// Search the dialogbox which contains the form
if (digi.box === null) return;
// Disable draggable event which are in conflict with input click on mobile
digi.box.removeEventListener("touchstart", disableEvent);
digi.box.addEventListener("touchstart", disableEvent, true);
}, false);
/* === FROM HERE ==========================
Other experiments
- Allow scrolling on long AITL offers
- Allow to enter price in exchanges form
======================================== */
// Trigger fix only if a databox is popup
document.getElementById("zone_dataBox").addEventListener('DOMNodeInserted', () => {
// objet ailt
var ailt = {};
ailt.pages = document.getElementsByClassName("aitl_page");
ailt.box = aitlPages[0].parentNode.parentNode.parentNode.parentNode;
// Check if the databox contains an aitl offer page
if (aitl.page.length == 0) return;
// Search for the AITL box
if (aitl.box === null) return;
// Disable draggable event which are in conflict with scroll
aitl.box.removeEventListener("touchstart", disableEvent);
aitl.box.addEventListener("touchstart", disableEvent, true);
}, false);
// Trigger fix only if a dialogbox is popup
document.getElementById("zone_dataBox").addEventListener('DOMNodeInserted', () => {
// objet price
var price = {};
price.input = document.getElementById("champ_credits");
price.form = priceInput.parentNode.parentNode;
price.box = priceForm.parentNode;
// Check if the dialogbox contains a digicode input
if (price.input === null) return;
// Search the parent form of the digicode
if (price.form === null) return;
// Search the dialogbox which contains the form
if (price.box === null) return;
// Disable draggable event which are in conflict with input click on mobile
price.box.removeEventListener("touchstart", disableEvent);
price.box.addEventListener("touchstart", disableEvent, true);
}, false);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment