sfc-utils 1.4.118 → 1.4.120
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 +3 -3
- package/package.json +1 -1
- package/regwall.js +60 -0
package/accountswap.js
CHANGED
|
@@ -34,9 +34,9 @@ const pollForAccount = async function (i, isNav) {
|
|
|
34
34
|
return false;
|
|
35
35
|
}
|
|
36
36
|
// Check again after 1 sec
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
// Check again after 1 sec using a Promise with async/await
|
|
38
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
39
|
+
return await pollForAccount(i + 1, isNav);
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
|
package/package.json
CHANGED
package/regwall.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// NOTE: Script meant to be called when the regwall is requested
|
|
2
|
+
// This script will listen for a successful registration, then run a function passed to it
|
|
3
|
+
const listenForRegSuccess = (resultFunc, resultParams) => {
|
|
4
|
+
return new Promise((resolve, reject) => {
|
|
5
|
+
if (window) {
|
|
6
|
+
let attempts = 0;
|
|
7
|
+
const checkForTarget = (innerResolve) => {
|
|
8
|
+
// Select the target element
|
|
9
|
+
const targetElement = document.querySelector(".bc_regwall_box");
|
|
10
|
+
if (targetElement) {
|
|
11
|
+
// Set up intersection observer
|
|
12
|
+
// Define the callback function
|
|
13
|
+
const observerCallback = (entries, observer) => {
|
|
14
|
+
entries.forEach((entry) => {
|
|
15
|
+
if (!entry.isIntersecting) {
|
|
16
|
+
// Wait for element to leave view, run the provided function
|
|
17
|
+
console.log("Element is out of view!");
|
|
18
|
+
// Perform your action here
|
|
19
|
+
resultFunc(resultParams);
|
|
20
|
+
innerResolve(true);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Create a new IntersectionObserver
|
|
26
|
+
const observerOptions = {
|
|
27
|
+
root: null, // Use the viewport as the root
|
|
28
|
+
threshold: 0, // 0 means trigger when the element is out of view
|
|
29
|
+
};
|
|
30
|
+
const observer = new IntersectionObserver(
|
|
31
|
+
observerCallback,
|
|
32
|
+
observerOptions
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// Start observing the target element
|
|
36
|
+
observer.observe(targetElement);
|
|
37
|
+
} else {
|
|
38
|
+
// If the target element isn't found, try again
|
|
39
|
+
attempts++;
|
|
40
|
+
if (attempts < 20) {
|
|
41
|
+
// Check for target every second
|
|
42
|
+
setTimeout(() => {
|
|
43
|
+
checkForTarget(innerResolve);
|
|
44
|
+
}, 200);
|
|
45
|
+
} else {
|
|
46
|
+
innerResolve("Regwall: No target found after many attempts");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
// Kick off check
|
|
51
|
+
checkForTarget(resolve);
|
|
52
|
+
} else {
|
|
53
|
+
resolve("Regwall: No window found");
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
module.exports = {
|
|
59
|
+
listenForRegSuccess,
|
|
60
|
+
};
|