英文:
Javascript automatic prompt choice
问题
这是一个来自提示的代码,当尝试向特定人发送电子邮件时出现,我想知道是否有可能在打开此提示时自动运行“继续”按钮,而无需单击它。一直在尝试自己实现,但我的JavaScript知识不允许我这样做。
示例提示
我尝试创建一个可以在Violentmonkey中实现的JavaScript代码,但我找不到实现的方法。
因此,代码的这部分负责“继续”的部分,但我无法想出如何使它自动按下:
Kn, {
onClick: $,
"data-testid": eI,
children: re.formatMessage({
id: "i18n.tco.ng.priceproposals.DIALOG_COMMUNICATION_SUBMIT"
})
如果我理解正确,"继续"按钮的ID是这个:"Normalize_normalize__5biS5.Button_button__PnIym"。
所以我尝试创建了一些东西,但它不起作用:
(function() {
'use strict';
window.addEventListener('beforeunload', function(event) {
event.preventDefault();
event.returnValue = '';
});
window.alert = function(message) {
console.log(message);
};
window.prompt = function(message) {
console.log(message);
return true;
};
window.confirm = function(message) {
console.log(message);
var continueAnywayButton = document.querySelector('Normalize_normalize__5biS5.Button_button__PnIym');
if (continueAnywayButton) {
continueAnywayButton.click();
return true;
} else {
return false;
}
};
})();
希望这有帮助。
英文:
This is a code from the prompt which appears when trying to send an e-mail to specific people, and I wonder if it's possible to make "Continue anyway" run automatically when this prompt is opened without having to click it. Been trying to achieve it myself, but my Javascript knowledge doesn't allow me to do it.
Prompt example
I tried creating a javascript code that would be implemented in Violentmonkey, but I can't find a way to do it..
So this part of the code is responsible for "continue anyway" part, but I can't come up with a way to make it so that it's automatically pressed
ya.jsx)(Kn, {
onClick: $,
"data-testid": eI,
children: re.formatMessage({
id: "i18n.tco.ng.priceproposals.DIALOG_COMMUNICATION_SUBMIT"
})
<!-- language: lang-js -->
JC = "PriceProposalContactConfirmDialog/createPPLButton", eI = "PriceProposalContactConfirmDialog/confirmButton", tI = "PriceProposalContactConfirmDialog/abortButton", PriceProposalContactConfirmDialog = V => {
let {
onConfirm: $,
onClose: Z,
onClickOpenPriceProposalDialog: ee,
showCreatePriceProposalButton: te
} = V;
const re = useIntl(),
onClickCreatePriceProposal = () => {
Z(),
ee()
};
return (0,
ya.jsx)(ConfirmDialog, {
headline: re.formatMessage({
id: "i18n.tco.ng.priceproposals.DIALOG_COMMUNICATION_HEADER"
}),
message: (0,
ya.jsx)("div", {
children: re.formatMessage({
id: "i18n.tco.ng.priceproposals.DIALOG_COMMUNICATION_INFO"
})
}),
onClose: Z,
customFooter: te ? (0,
ya.jsxs)(ya.Fragment, {
children: [(0,
ya.jsx)(Kn, {
buttonStyle: "primary",
autoFocus: !0,
onClick: onClickCreatePriceProposal,
"data-testid": JC,
children: re.formatMessage({
id: "i18n.tco.ng.priceproposals.SUBMIT_DIALOG_HEADER"
})
}), (0,
ya.jsx)(Kn, {
onClick: $,
"data-testid": eI,
children: re.formatMessage({
id: "i18n.tco.ng.priceproposals.DIALOG_COMMUNICATION_SUBMIT"
})
}), (0,
ya.jsx)(Kn, {
onClick: Z,
buttonStyle: "text",
"data-testid": tI,
children: re.formatMessage({
id: "i18n.tco.ng.ABORT"
})
})]
}) : (0,
ya.jsxs)(ya.Fragment, {
children: [(0,
ya.jsx)(Kn, { **
onClick: $,
buttonStyle: "primary",
autoFocus: !0,
"data-testid": eI,
children: re.formatMessage({ **
id: "i18n.tco.ng.priceproposals.DIALOG_COMMUNICATION_SUBMIT"
})
}), (0,
ya.jsx)(Kn, {
onClick: Z,
buttonStyle: "text",
"data-testid": tI,
children: re.formatMessage({
id: "i18n.tco.ng.ABORT"
})
})]
})
})
}
<!-- end snippet -->
If I understand it correctly, button ID for "Continue anyway" is this: "Normalize_normalize__5biS5.Button_button__PnIym"
So I tried creating something myself, but it doesn't work..
(function() {
'use strict';
window.addEventListener('beforeunload', function(event) {
event.preventDefault();
event.returnValue = '';
});
window.alert = function(message) {
console.log(message);
};
window.prompt = function(message) {
console.log(message);
return true;
};
window.confirm = function(message) {
console.log(message);
var continueAnywayButton = document.querySelector('Normalize_normalize__5biS5.Button_button__PnIym');
if (continueAnywayButton) {
continueAnywayButton.click();
return true;
} else {
return false;
}
};
})();
答案1
得分: 1
谢谢你的评论,我想出了一种方法来检测出现提示时显示的文本,如果文本存在,则选择“继续 anyway” 选项。
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论