window.consentApi.unblock: Check if a given URL / string is blocked by a Content Blocker:
window.consentApi.unblock
Example (ES5):
(window.consentApi && window.consentApi.unblock("player.vimeo.com") || Promise.resolve()).then(function() { console.log("Consent for Vimeo given, unlock content...!");}); Copy
(window.consentApi && window.consentApi.unblock("player.vimeo.com") || Promise.resolve()).then(function() { console.log("Consent for Vimeo given, unlock content...!");});
Example (ES6, TS):
(window.consentApi?.unblock("player.vimeo.com") || Promise.resolve()).then(() => { console.log("Consent for Vimeo given, unlock content...!");}); Copy
(window.consentApi?.unblock("player.vimeo.com") || Promise.resolve()).then(() => { console.log("Consent for Vimeo given, unlock content...!");});
Since v5.0.4: The API also supports passing an HTMLElement as the first argument. When the element is blocked, the returned Promise is resolved immediately after unblocking:
HTMLElement
window.consentApi.unblock(document.querySelector("iframe")).then(() => console.log("I got loaded!")); Copy
window.consentApi.unblock(document.querySelector("iframe")).then(() => console.log("I got loaded!"));
Optional
window.consentApi.unblock
: Check if a given URL / string is blocked by a Content Blocker:Example (ES5):
Example (ES6, TS):
Since v5.0.4: The API also supports passing an
HTMLElement
as the first argument. When the element is blocked, the returned Promise is resolved immediately after unblocking: