Shortcut to auto login to a web page

Hello, I want to ask about how to make an auto login or auto fill username password on a website which I wrote below via a shortcut or scriptable

Link : E-Absensi

here I am complaining because the username and password for logging in to a website for my work are very long and complicated. I want to make or make it easier to log in on this website via a shortcut, please help to create an auto login script and auto fill username and password

Thank You.

Hello,

Is the save password feature not working on your browser? I would go there first. You could check in your browser’s settings if you did not accidentally say “never save password” for that url specifically.

If not… Are you allowed to add browser extensions to your browser? I am using tampermonkey to autofill my login field and focus on my password field because autosave password doesn’t work on that page. Here’s what my script content looks like:

(function() {
    'use strict';

    // Your code here...
    document.getElementById("ctl10_name").value = "sebastienkb@myemployer.com";
    document.getElementById("ctl10_password").focus();
})();

Important note: I don’t recommend putting passwords directly in code! That’s why I used focus() and type.

here I use an iPhone IOS 16 to log in to the website, for shortcuts I use scriptable and to open the website I use the Safari app. Is there a solution for this?

from the script that I made, the drawback is that when this script is run, the username and password run smoothly, but this script has no response to login, is there an error in the script?

let user = ‘67433344566777’;
let pass = ‘532799888’;

let v = new WebView();
await v.loadURL(‘https://e-absensi.rsudrsoetomo.jatimprov.go.id/’);

let js = `let user = ‘${user}’;
let pass = ‘${pass}’;

document.getElementById(‘nomorindukpegawai’).value = user;
document.getElementById(‘LoginForm_password’).value = pass;
document.getElementById(‘ap-claim’).value = user;
document.getElementById(‘ap-credential-autofill-hint’).value = user;
document.getElementById(‘ap-credential-autofill-hint’).dataset.claim = user;

document.getElementById(‘login-button’).click();`;

v.present(); v.evaluateJavaScript(js);
await v.waitForLoad();

const result = await v.evaluateJavaScript(js);

// use result in the widget

This script is made via app scriptable

Ah, right! My answer only applies to desktops. The use of Scriptable should have been my hint that you were only on your phone.

You’re applying exactly what I did with the lines

document.getElementById('nomorindukpegawai').value = user;
document.getElementById('LoginForm_password').value = pass;

So far I understand that you prepare a multiline script in the js variable for later execution.

  • Could it be that v.evaluateJavaScript(js); needs to happen after awaitForLoad(); ?
  • Could it be that you’re using the “wrong” apostrophe? There’s a difference between and '
  • Could you try by putting your script in a single line? (; is a separator anyway)

thank you for the script you provided. but what i mean is on login action its not working

Did you try to replace all your apostrophes with exactly ' ? This is important in javascript.

an error appears when like this

2023-02-09 15:07:18: Kesalahan pada baris 8: SyntaxError: Pengenal tak terduga ‘pengguna’. Diharapkan ‘;’ setelah deklarasi variabel.

2023-02-09 15:18:43: Error on line 22:45: ReferenceError: Can’t find variable: Js

and got an error like this after changing ’ to `

Can’t find variable: Js

Make sure it’s js (lowercase j) and not Js.

and got an error like this after changing ’ to `

No need to change the apostrophe to a backtick.

This is what I have in mind

let user = '67433344566777';
let pass = '532799888';

let v = new WebView();
await v.loadURL('https://e-absensi.rsudrsoetomo.jatimprov.go.id/');

let js = `
  let user = '${user}';
  let pass = '${pass}';
  document.getElementById('nomorindukpegawai').value = user;
  document.getElementById('LoginForm_password').value = pass;
  document.getElementById('ap-claim').value = user;
  document.getElementById('ap-credential-autofill-hint').value = user;
  document.getElementById('ap-credential-autofill-hint').dataset.claim = user;
  document.getElementById('login-button').click();
`;

v.present();
await v.waitForLoad();

const result = await v.evaluateJavaScript(js);

// use result in the widget

Alternative (it’s uglier, but doesn’t use backticks):

let v = new WebView();
await v.loadURL('https://e-absensi.rsudrsoetomo.jatimprov.go.id/');

let js = 'let user = "67433344566777"; let pass = "532799888"; document.getElementById("nomorindukpegawai").value = user; document.getElementById("LoginForm_password").value = pass; document.getElementById("ap-claim").value = user; document.getElementById("ap-credential-autofill-hint").value = user; document.getElementById("ap-credential-autofill-hint").dataset.claim = user; document.getElementById("login-button").click();';

v.present();
await v.waitForLoad();

const result = await v.evaluateJavaScript(js);

// use result in the widget

thank you sir i’ll try this code wait