Estoy usando un script tampermonkey pero tengo este error. No sé cómo solucionar este problema.
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] } })Parece que al script le faltan los símbolos + ...
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 ] } })Intenta usar `...`;
Puede buscar sobre la cadena de plantilla en 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 ] } }) Además, puedes probar como a continuación;
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@" > ',