[英]How to fix issue on tampermonkey script
我正在使用 tampermonkey 脚本,但出现此错误。 我不知道如何解决这个问题。
document.onkeypress = async function(e) {
e = e || window.event;
var charCode = (typeof e.which == "number") ? e.which : e.keyCode;
if (String.fromCharCode(charCode) === '=') {
const {
value: formValues
} = await Swal.fire({
title: 'Enter your credentials ',
html: '<input id="swal-input1" class="swal2-input" placeholder="email"
type = "text"
value = "kor@gmail.com" > ' +
'<input id="swal-input2" class="swal2-input" placeholder="password"
type = "password"
value = "A23@" > ',
focusConfirm: false,
preConfirm: () => {
return [
document.getElementById('swal-input1').value,
document.getElementById('swal-input2').value
][![enter image description here][1]][1]
}
})
该脚本似乎缺少一个+
符号...
document.onkeypress = async function(e) {
e = e || window.event;
var charCode = (typeof e.which == "number") ? e.which : e.keyCode;
if (String.fromCharCode(charCode) === '=') {
const {
value: formValues
} = await Swal.fire({
title: 'Enter your credentials ',
html: '<input id="swal-input1" class="swal2-input"' + 'placeholder="email"'
+'type = "text"'
+'value = "kor@gmail.com" > ' +
'<input id="swal-input2" class="swal2-input" placeholder="password"'+
'type = "password"'+
'value = "A23@" > ',
focusConfirm: false,
preConfirm: () => {
return [
document.getElementById('swal-input1').value,
document.getElementById('swal-input2').value
]
}
})
尝试使用 `... `;
您可以在 javascript 中搜索模板字符串。
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals
document.onkeypress = async function(e) {
e = e || window.event;
var charCode = (typeof e.which == "number") ? e.which : e.keyCode;
if (String.fromCharCode(charCode) === '=') {
const {
value: formValues
} = await Swal.fire({
title: 'Enter your credentials ',
html: `<input id="swal-input1" class="swal2-input" placeholder="email" type = "text" value = "kor@gmail.com" >
<input id="swal-input2" class="swal2-input" placeholder="password" type = "password" value = "A23@" > `,
focusConfirm: false,
preConfirm: () => {
return [
document.getElementById('swal-input1').value,
document.getElementById('swal-input2').value
]
}
})
另外,您可以像下面这样尝试;
html: '<input id="swal-input1" class="swal2-input" placeholder="email" type="text" value="kor@gmail.com"> <input id="swal-input2" class="swal2-input" placeholder="password" type="password" value="A23@" > ',
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.