Skip to content

Instantly share code, notes, and snippets.

@lan2720
Last active September 19, 2023 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lan2720/b70bed64beb58754f40dca162f6cbc11 to your computer and use it in GitHub Desktop.
Save lan2720/b70bed64beb58754f40dca162f6cbc11 to your computer and use it in GitHub Desktop.
油猴脚本autoLoginUsVisa.js
// ==UserScript==
// @name autoLoginUsVisa
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author jarvixwang
// @match https://portal.ustraveldocs.com/
// @icon https://www.google.com/s2/favicons?sz=64&domain=ustraveldocs.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
// console.log("this hello comes from tampermonkey!");
const account_info = {
username: '***',
password: '***',
};
const elem_xpath = {
username: 'loginPage:SiteTemplate:siteLogin:loginComponent:loginForm:username',
password: 'loginPage:SiteTemplate:siteLogin:loginComponent:loginForm:password',
login_button: 'loginPage:SiteTemplate:siteLogin:loginComponent:loginForm:loginButton',
};
function loginForMe(){
document.getElementById(elem_xpath.username).value = account_info.username;
document.getElementById(elem_xpath.password).value = account_info.password;
const checkbox = document.evaluate("//input[@type='checkbox']",
document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
checkbox.click();
const button = document.getElementById(elem_xpath.login_button);
button.click();
console.log("login successfully!");
}
// 登录
loginForMe();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment