forked from yarkable/szu-newsboard-spider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathweb.js
57 lines (45 loc) · 1.35 KB
/
web.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function get_login_element(id_selector, password_selector) {
let id_e = document.querySelector(id_selector);
let password_e = document.querySelector(password_selector);
let result = {
'success': (id_e != null && password_e != null),
'id': id_e,
'password': password_e
}
return result;
}
window.get_login_element = get_login_element;
function fill_login_form(id, password) {
let results = get_login_element("input#username", "input#password")
if (results.success === true) {
results.id.value = id
results.password.value = password
}
}
window.fill_login_form = fill_login_form;
function do_login() {
let btn = document.querySelector("#login_submit")
if (btn == null) {
btn = document.querySelector("##login_submit")
}
btn.click()
}
window.do_login = do_login;
function setInput(input, text) {
input.value = text
const evt = new Event("input", {"bubbles": true, "cancelable": false});
input.dispatchEvent(evt);
}
window.setInput = setInput;
// debug code start
// (function () {
// let iframe = document.createElement('iframe')
// document.body.appendChild(iframe)
// window.console = iframe.contentWindow.console
// }())
// debug code end
function is_login() {
let url = document.URL
return !url.includes("login");
}
window.is_login = is_login;