我有一个用户脚本,当我单击+1按钮(我创建了它)时,它可以正常工作,它可以进行获取和发布呼叫。但是我需要观看网站的发送消息按钮。
<button class="btn btn-primary" type="submit" disabled="">Send message</button>
是按钮,并且btn和btn-primary类也添加到其他按钮。
我正在执行ButtonClickaction函数上的操作。我如何观看“发送消息”按钮上的点击。
观看此按钮有什么解决方法?
// ==UserScript==
// @name Emre's Users Script.
// @description Example Script.
// @match *://example.com*
// @grant GM_addStyle
// @grant GM.xmlHttpRequest
// @version 0.1 - Alpha
// ==/UserScript==
/*--- Create a button in a container div. It will be styled and
positioned with CSS.
*/
var zNode = document.createElement ('div');
zNode.innerHTML = '<button id="myButton" type="button">'
+ '+1 EKLE</button><div style="color: white;" id="mydiv">Yükleniyor</div><div style="color: white;font-size: 14px;" id="mydiv1"></div> '
;
zNode.setattribute ('id','myContainer');
document.body.appendChild (zNode);
GM.xmlHttpRequest({
method: "GET",url: "https://example.com/ajax.php?id=21",headers: {
"User-Agent": "Mozilla/5.0","accept": "text/xml"
},onload: function(response) {
document.getElementById("mydiv").innerHTML = response.responseText;
}
});
GM.xmlHttpRequest({
method: "GET",url: "https://example.com/ajax.php?aylik=buay",onload: function(response) {
document.getElementById("mydiv1").innerHTML = response.responseText;
}
});
//--- activate the newly added button.
document.getElementById ("myButton").addEventListener (
"click",ButtonClickaction,false
);
function ButtonClickaction (zEvent) {
/*--- For our dummy action,we'll just add a line of text to the top
of the screen.
*/
/*var zNode = document.createElement ('p');
zNode.innerHTML = 'The button was clicked.';
document.getElementById ("myContainer").appendChild (zNode);*/
GM.xmlHttpRequest({
method: "POST",url: "https://example.com/ajax.php?ekle=1&id=21",data: "username=johndoe&password=xyz123zz",onload: function(response) {
document.getElementById("mydiv").innerHTML = response.responseText;
},headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
});
GM.xmlHttpRequest({
method: "GET",onload: function(response) {
document.getElementById("mydiv1").innerHTML = response.responseText;
}
});
}
//--- Style our newly added elements using CSS.
GM_addStyle ( `
#myContainer {
position: fixed;
bottom: 9px;
right: 10px;
font-size: 20px;
background: #e91e63;
border: 3px outset black;
margin: 5px;
opacity: 0.9;
z-index: 1100;
padding: 5px 20px;
}
#myButton {
cursor: pointer;
margin-left: 23px;
}
#myContainer p {
color: red;
background: white;
}
` );
有人会帮助吗?自20天以来,我一直处于困境。