DC - MobileFixes

Fix player interactions with draggable boxes

目前为 2019-11-07 提交的版本。查看 最新版本

// ==UserScript==
// @name         DC - MobileFixes
// @namespace    http://tampermonkey.net/
// @version      0.11
// @description  Fix player interactions with draggable boxes
// @author       Ajira
// @match        https://www.dreadcast.net/Main
// @grant        none
// ==/UserScript==

(function() {
    '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', function() {
        // Check if the dialogbox contains a digicode input
        var digiInput = document.getElementById("lb_textinput_digicode");
        if (digiInput === null) { return; }
        // Search the parent form of the digicode
        var digiForm = digiInput.parentNode.parentNode;
        if (digiForm === null) { return; }
        // Search the dialogbox which contains the form
        var digiBox = digiForm.parentNode.parentNode;
        if (digiBox === null) { return; }
        // Disable draggable event which are in conflict with input click on mobile
        digiBox.removeEventListener("touchstart", disableEvent);
        digiBox.addEventListener("touchstart", disableEvent, true);
    }, false);

    /* === FROM HERE =======================
       Other experiments
       - Allow scrolling on long AITL offers
    ===================================== */

    // Trigger fix only if a databox is popup
    document.getElementById("zone_dataBox").addEventListener('DOMNodeInserted', function() {
        // Check if the databox contains an aitl offer page
        var aitlPages = document.getElementsByClassName("aitl_page");
        if (aitlPages.length == 0) { return; }
        // Search for the AITL box
        var aitlBox = aitlPages[0].parentNode.parentNode.parentNode.parentNode;
        if (aitlBox === null) { return; }
        // Disable draggable event which are in conflict with scroll
        aitlBox.removeEventListener("touchstart", disableEvent);
        aitlBox.addEventListener("touchstart", disableEvent, true);
    }, false);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址