如何在TampermonKey脚本上解决问题

发布于 2025-01-25 10:40:50 字数 1273 浏览 1 评论 0 原文

我正在使用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 = "[email protected]" > ' +
            '<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]
            }
        })

I am using a tampermonkey script but I have this error. I don't know how to fix this issue.

the error displayed
the source

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 = "[email protected]" > ' +
            '<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]
            }
        })

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

紫竹語嫣☆ 2025-02-01 10:40:50

尝试使用``...';
您可以在JavaScript中搜索模板字符串。

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 = "[email protected]" >
                       <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="[email protected]"> <input id="swal-input2" class="swal2-input" placeholder="password" type="password" value="A23@" > ',

Try to use ` ... ` ;
You can search about template string in 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 = "[email protected]" >
                       <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
                    ]
                }
            })

Also, you can try like below;

html: '<input id="swal-input1" class="swal2-input" placeholder="email" type="text" value="[email protected]"> <input id="swal-input2" class="swal2-input" placeholder="password" type="password" value="A23@" > ',
新雨望断虹 2025-02-01 10:40:50

该脚本似乎缺少+符号...

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 = "[email protected]" > ' +
            '<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
                ]
            }
        })

The script seems to be missing a + symbols ...

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 = "[email protected]" > ' +
            '<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
                ]
            }
        })
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文