Autologin with Inappbrowser on an external website?

心已入冬 提交于 2019-12-02 05:19:57

Yes, it should be possible. You just need to connect proper handler to loadstop event and then use local storage to store the usernames and passwords once submit is hit and if already existing, auto-fill them.

function loadStopped() {
    // Here use JavaScript to manipulate the actual page on hand.
    // Can't really give better description about what to do, but something like this:
    var username = "";
    if (localStorage.getItem("username") !== null) {
        username = localStorage.getItem("username");
    }
    var password = "";
    if (localStorage.getItem("password") !== null) {
        password = localStorage.getItem("password");
    }
    document.getElementById("username_field").value = username;
    document.getElementById("password_field").value = password;
    // document.getElementById("the_form").submit();
    document.getElementById("the_form").addEventListener("submit", function() {
        localStorage.setItem("username", document.getElementById("username_field").value);
        localStorage.setItem("password", document.getElementById("password_field").value);
    });
}
ref = window.open('http://google.com', '_self', 'location=yes');
ref.addEventListener('loadstop', loadStopped);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!