Last active
September 19, 2023 02:25
-
-
Save lan2720/b70bed64beb58754f40dca162f6cbc11 to your computer and use it in GitHub Desktop.
油猴脚本autoLoginUsVisa.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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