sfc-utils 1.4.172 → 1.4.173
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/accountswap.js +7 -16
- package/package.json +1 -1
package/accountswap.js
CHANGED
|
@@ -8,13 +8,12 @@ const attachSigninHandler = async function () {
|
|
|
8
8
|
let tries = 0;
|
|
9
9
|
const maxTries = 20; // 20 * 500ms = 10 seconds
|
|
10
10
|
while (!attachedRealm && tries < maxTries) {
|
|
11
|
+
tries++;
|
|
11
12
|
const signinButton = document.querySelector(".hnp-signin");
|
|
12
13
|
if (signinButton && !signinButton.dataset.realmAttached) {
|
|
13
14
|
signinButton.dataset.realmAttached = "true";
|
|
14
|
-
console.log("Attaching signin handler");
|
|
15
15
|
signinButton.onclick = function (e) {
|
|
16
|
-
if (window
|
|
17
|
-
console.log("Logging in!");
|
|
16
|
+
if (window?.treg?.realm?.core) {
|
|
18
17
|
window.treg.realm.core.login();
|
|
19
18
|
}
|
|
20
19
|
e.preventDefault();
|
|
@@ -24,7 +23,6 @@ const attachSigninHandler = async function () {
|
|
|
24
23
|
} else {
|
|
25
24
|
// Wait and try again
|
|
26
25
|
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
27
|
-
tries++;
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
28
|
};
|
|
@@ -35,16 +33,12 @@ const swapSubscribeForAccount = async function () {
|
|
|
35
33
|
let tries = 0;
|
|
36
34
|
const maxTries = 20; // 20 * 500ms = 10 seconds
|
|
37
35
|
while (!swapped && tries < maxTries) {
|
|
36
|
+
tries++;
|
|
38
37
|
if (window?.treg?.identity?.id) {
|
|
39
38
|
const rightBlock = document.querySelector(".nav2-right");
|
|
40
|
-
if (rightBlock) {
|
|
41
|
-
if (!rightBlock.innerText) {
|
|
42
|
-
// If there's no innerText, keep waiting
|
|
43
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
39
|
+
if (rightBlock && rightBlock.innerText) {
|
|
46
40
|
rightBlock.innerHTML = `<a id="nav2-sub-box" href="${accountURL}"><div>Account</div></a>`;
|
|
47
|
-
if (window
|
|
41
|
+
if (window?.treg?.realm?.iframeProfile) {
|
|
48
42
|
const subButton = document.querySelector("#nav2-sub-box");
|
|
49
43
|
if (subButton) {
|
|
50
44
|
subButton.onclick = function (e) {
|
|
@@ -52,15 +46,12 @@ const swapSubscribeForAccount = async function () {
|
|
|
52
46
|
e.preventDefault();
|
|
53
47
|
e.stopPropagation();
|
|
54
48
|
};
|
|
49
|
+
swapped = true;
|
|
55
50
|
}
|
|
56
51
|
}
|
|
57
|
-
swapped = true;
|
|
58
52
|
}
|
|
59
|
-
} else {
|
|
60
|
-
// Wait and try again
|
|
61
|
-
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
62
|
-
tries++;
|
|
63
53
|
}
|
|
54
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
64
55
|
}
|
|
65
56
|
};
|
|
66
57
|
|