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
ElementReady is nothing but a requestAnimationFrame-based loop that calls querySelector until found. This means we can offer a simple wrapper that does this with any detection:
Pure DOM-based detections would be perfect this way;
Pure URL-based detections wouldn’t need it;
Mixed detections would unnecessarily test the URL every time, but probably we don’t have to worry about the “performance impact” of this
Alternatively the detections could internally replace exists with an async version, but it would be impossible to effectively handle multiple checks in the same detection:
awaitcanEditSidebar({async: true})
fregante
changed the title
How to turn DOM-based into checks that can be run with elementReady?
Add elementReady-like helper for DOM detections
Jul 28, 2022
Sometimes we want to test whether a page matches before it's done downloading, this can be done by passing a selector to
element-ready
.I have 2 ideas:
Static definitions
Instead of being just a function, we can define the detections as a list of constraints like:
But this gets wordy FAST
Duplicate functions
const canUserEditOrg = (url) => isOrganizationProfile() && exists('.pagehead-tabs-item[href$="/settings/profile"]') + const canUserEditOrgAsync = async (url) => isOrganizationProfile() && await existsReady('.pagehead-tabs-item[href$="/settings/profile"]')
The text was updated successfully, but these errors were encountered: