Fix player interactions with draggable boxes
// ==UserScript==// @name DC - MobileFixes// @namespace http://tampermonkey.net/// @version 0.14// @description Fix player interactions with draggable boxes// @author Ajira// @match https://www.dreadcast.net/Main// @match https://www.dreadcast.eu/Main// @grant none// ==/UserScript==(function() {'use strict';/* TODO ==============================================- Should loop on class identified objects like AITL=================================================== */// Stop event propagationfunction disableEvent(event) {event.stopPropagation();}// Trigger fix only if a dialogbox is popupdocument.getElementById("zone_lightBox").addEventListener('DOMNodeInserted', function() {// Check if the dialogbox contains a digicode inputvar digiInput = document.getElementById("lb_textinput_digicode");if (digiInput === null) { return; }// Search the parent form of the digicodevar digiForm = digiInput.parentNode.parentNode;if (digiForm === null) { return; }// Search the dialogbox which contains the formvar digiBox = digiForm.parentNode.parentNode;if (digiBox === null) { return; }// Disable draggable event which are in conflict with input click on mobiledigiBox.removeEventListener("touchstart", disableEvent);digiBox.addEventListener("touchstart", disableEvent, true);}, false);/* === FROM HERE ==========================Other experiments- Allow scrolling on long AITL offers- Allow to enter price in exchanges form- Allow to use decks- Allow to set price in centrale======================================== */// Trigger fix only if a databox is popupdocument.getElementById("zone_dataBox").addEventListener('DOMNodeInserted', function() {// Check if the databox contains an aitl offer pagevar aitlPages = document.getElementsByClassName("aitl_page");if (aitlPages.length == 0) { return; }// Search for the AITL boxvar aitlBox = aitlPages[0].parentNode.parentNode.parentNode.parentNode;if (aitlBox === null) { return; }// Disable draggable event which are in conflict with scrollaitlBox.removeEventListener("touchstart", disableEvent);aitlBox.addEventListener("touchstart", disableEvent, true);}, false);// Trigger fix only if a dialogbox is popupdocument.getElementById("zone_dataBox").addEventListener('DOMNodeInserted', function() {// Check if the dialogbox contains a exchange inputvar priceInput = document.getElementById("champ_credits");if (priceInput === null) { return; }// Search the parent form of the exchangevar priceForm = priceInput.parentNode.parentNode;if (priceForm === null) { return; }// Search the dialogbox which contains the formvar priceBox = priceForm.parentNode;if (priceBox === null) { return; }// Disable draggable event which are in conflict with input click on mobilepriceBox.removeEventListener("touchstart", disableEvent);priceBox.addEventListener("touchstart", disableEvent, true);}, false);// Trigger fix only if a dialogbox is popupdocument.getElementById("zone_dataBox").addEventListener('DOMNodeInserted', function() {// Check if the databox contains a deckvar deckFroms = document.getElementsByClassName("deck_main");if (deckFroms.length == 0) { return; }// Search for the deck screenvar deckScreen = deckFroms[0].parentNode.parentNode.parentNode;if (deckScreen === null) { return; }// Disable draggable event which are in conflict with scrolldeckScreen.removeEventListener("touchstart", disableEvent);deckScreen.addEventListener("touchstart", disableEvent, true);}, false);// Trigger fix only if a dialogbox is popupdocument.getElementById("zone_lightBox").addEventListener('DOMNodeInserted', function() {// Check if the dialogbox contains price inputvar centraleForm = document.getElementById("lb_form_centrale_vente_prix");if (centraleForm == null) { return; }console.info(centraleForm);// Centrale form dialogboxvar centraleBox = centraleForm.parentNode.parentNode.parentNode.parentNode;if (centraleBox === null) { return; }console.info(centraleBox);// Disable draggable event which are in conflict with input click on mobilecentraleBox.removeEventListener("touchstart", disableEvent);centraleBox.addEventListener("touchstart", disableEvent, true);}, false);})();