forked from lapcat/AppStoreConnect
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent.js
More file actions
94 lines (87 loc) · 2.81 KB
/
content.js
File metadata and controls
94 lines (87 loc) · 2.81 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Copyright (c) 2022 Jeff Johnson. All rights reserved.
(function() {
'use strict';
const AppleID = ''; // Required Apple ID
let account = document.getElementById("account_name_text_field");
if (account !== null) {
ASCLogin();
} else {
const accountObserver = new MutationObserver(function (records) {
account = document.getElementById("account_name_text_field");
if (account !== null) {
accountObserver.disconnect();
ASCLogin();
}
});
accountObserver.observe(document, {childList: true, subtree: true});
}
function ASCLogin() {
if (account.value.length > 0) {
ContinueWithPassword();
return;
}
if (AppleID.length === 0) {
window.alert("AppleID required!");
return;
}
account.dispatchEvent(new Event("focus"));
account.value = AppleID;
account.dispatchEvent(new Event("input"));
const button = document.getElementById("sign-in");
if (button === null) {
console.log("ASC missing sign-in button");
return;
}
if (button.disabled) {
const disabledObserver = new MutationObserver(function (records) {
if (!button.disabled) {
disabledObserver.disconnect();
button.click();
ContinueWithPassword();
}
});
disabledObserver.observe(button, {attributes: true, attributeFilter: ["disabled"]});
} else {
button.click();
ContinueWithPassword();
}
}
function ASCFocusPassword() {
// Only works in Chrome, not Safari
const password = document.getElementById("password_text_field");
if (password === null) {
console.log("ASC missing password_text_field");
return;
}
if (password.getAttribute("tabindex") === "-1") {
const tabindexObserver = new MutationObserver(function (records) {
if (password.getAttribute("tabindex") !== "-1") {
tabindexObserver.disconnect();
password.focus();
}
});
tabindexObserver.observe(password, {attributes: true, attributeFilter: ["tabindex"]});
} else {
password.focus();
}
}
function ContinueWithPassword() {
let button = document.getElementById("continue-password");
if (button !== null) {
button.click();
ASCFocusPassword();
} else {
const continueObserver = new MutationObserver(function (records) {
button = document.getElementById("continue-password");
if (button !== null) {
continueObserver.disconnect();
setTimeout(() => {
button.click();
ASCFocusPassword();
}, 500);
}
});
continueObserver.observe(document, {childList: true, subtree: true});
}
}
})();