第一个按钮无法单击

时间:2019-10-30 00:29:50

标签: button

我正在尝试创建脚本来更改游戏的帽子(http:/moomoo.io/),但是我创建了一个容器或有2个按钮,如果我只放1个按钮,但是如果我都放只有一种有效,因为另一种是灰色的,我们不能单击它! 代码:

Tampermonkey的UserScript代码:

// @name        _Adding a live button
// @description Adds live example button, with styling.
// @match       *://dev.moomoo.io/*
// @require https://greasyfork.org/scripts/368273-msgpack/code/msgpack.js?version=598723
// @require http://code.jquery.com/jquery-3.3.1.min.js
// @require http://code.jquery.com/jquery-1.12.4.min.js
// @require https://code.jquery.com/ui/1.12.0/jquery-ui.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.3.0/jquery-confirm.min.js
// @grant       GM_addStyle
// ==/UserScript==
var PolarHead = 44;
var MonkeyHead = 38;
var zNode = document.createElement('div');
zNode.innerHTML = '<button id="myButton" type="button">'
                + '</button>'
                ;
zNode.setAttribute('id', 'myContainer');
document.body.appendChild(zNode);
document.getElementById("myButton").addEventListener (
    "click", ButtonClickAction, false
);
function ButtonClickAction(zEvent) {
    var zNode = document.createElement('p');
    zNode.innerHTML = storeEquip(PolarHead).break;
    document.getElementById("myContainer").appendChild(zNode);
}
var zNode2 = document.createElement('div');
zNode2.innerHTML = '<button id="myButton2" type="button">'
                + '</button>'
                ;
zNode2.setAttribute('id', 'myContainer');
document.body.appendChild(zNode2);
document.getElementById("myButton2").addEventListener (
    "click", ButtonClickAction2, false
);
function ButtonClickAction2(zEvent) {
    var zNode2 = document.createElement('p');
    zNode2.innerHTML = storeEquip(MonkeyHead).break;
    document.getElementById("myContainer").appendChild(zNode2);
}```

The CSS code:

```GM_addStyle ( `
    #myContainer {
        position:               absolute;
        top:                    0;
        left:                   0;
        font-size:              20px;
        background:             black;
        border:                 3px outset black;
        margin:                 5px;
        opacity:                0.5;
        z-index:                1100;
        padding:                5px 20px;
    }
    #myButton {
        cursor:                 pointer;
        background: no-repeat center/80% url("http://moomoo.io/img/hats/hat_44.png");
        width:                  33px;
        height:                 33px;
    }
    #myButton2 {
        cursor:                 pointer;
        background: no-repeat center/80% url("http://moomoo.io/img/hats/hat_38.png");
        margin-left:            33px;
        width:                  33px;
        height:                 33px;
    }
    #myContainer p {
    }
` );```

Thanks to response, the code is only for tampermonkey

cordially
Ympax

0 个答案:

没有答案