Xin chào các bạn, bài viết này mình chia sẻ các bạn script dùng đặt trên Bookmark trình duyệt dùng để Login Gmail.

[WEB]Tự động đăng nhập gmail bằng bookmark Chrome

Thường chúng ta sẽ sử dụng Vanilla JavaScript để viết script thực hiện

Các bạn có thể viết script tùy ý để xử lý trên web khi mình click vào nút trên toolbar bookmark.

Các bạn có thể xem video hướng dẫn code và demo auto login Gmail.

Source code:

javascript: (function () {    
    var username = '[email protected]';
    var password = 'xxxx';
    var speed = 50;
    var i = 0;
    var j = 0;
    var flag = true;
    function sleep(ms) {
        return new Promise(resolve => setTimeout(resolve, ms));
    }
    function typeUserName() {

        if (i < username.length) {
            document.querySelectorAll('input[type="email"]')[0].setAttribute("autocomplete", "off");
            document.querySelectorAll('input[type="email"]')[0].value += username.charAt(i);
            i++;
            setTimeout(typeUserName, speed);
        } else {
            var button = document.querySelectorAll("button");

            for (let i = 0; i < button.length; i++) {
                if (button[i].innerText == "Next") {
                    button[i].click();
                    console.log("tìm thấy button next");
                    setTimeout(typePassword, 1500);
                }
            }
        }
    }
    function typePassword() {
        console.log("Bắt đầu đăng nhập password");
        if (flag) {
            if (i >= username.length) {
                j = 0;
                document.querySelectorAll('input[type="password"]')[0].value = "";
                flag = false;
            }
        }

        if (j < password.length) {
            document.querySelectorAll('input[type="password"]')[0].setAttribute("autocomplete", "off");
            document.querySelectorAll('input[type="password"]')[0].value += password.charAt(j);
            j++;
            setTimeout(typePassword, speed);
        } else {
            var button = document.querySelectorAll("button");

            for (let i = 0; i < button.length; i++) {
                if (button[i].innerText == "Next") {
                    button[i].click();
                    console.log("tìm thấy button next 2");
                    sleep(1500);
                }
            }


        }
    }
    typeUserName();
})()

Sau khi biết script xong, các bạn truy cập vào đường link bên dưới để encode.

https://chriszarate.github.io/bookmarkleter/

Chi tiết cụ thể các bạn có thể tham khảo ở video hướng dẫn nhé.
Chúc các bạn thành công.