You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+24Lines changed: 24 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,30 @@ if (pageDetect.isOrganizationProfile()) {
67
67
}
68
68
```
69
69
70
+
### Async detections with `waitFor`
71
+
72
+
The `waitFor` helper function allows you to wait for a detection to become true by repeatedly checking it on each animation frame. This is useful for DOM-based detections that need to wait for elements to appear before the document is fully loaded.
// Wait for the detection to return true or for the document to be complete
79
+
if (!awaitutils.waitFor(isOrganizationProfile)) {
80
+
return; // Not an organization profile
81
+
}
82
+
83
+
// The page is now confirmed to be an organization profile
84
+
console.log('On organization profile!');
85
+
}
86
+
```
87
+
88
+
The `waitFor` function:
89
+
- Repeatedly calls the detection function on each animation frame
90
+
- Stops when the detection returns `true` or when `document.readyState` is `'complete'`
91
+
- Returns the final result of the detection
92
+
- Works with any detection function that returns a boolean
93
+
70
94
## Related
71
95
72
96
-[github-reserved-names](https://github.com/Mottie/github-reserved-names) - Get a list, or check if a user or organization name is reserved by GitHub.
0 commit comments