Content Blockers
JavaScript Types
ContentBlockerItem
ContentBlockerItem {
description: string;
hosts: string[];
id: string;
javaScriptGlobal: string;
javaScriptInitialization: string;
name: string;
providerId: string;
serviceId: string | null;
}Content Blocker Information by Content Blocker ID
window.BorlabsCookie.ContentBlocker.findByContentBlockerId(contentBlockerId: string): ContentBlockerItem | nullDialog
Reopen the Dialog
There is no JavaScript API function available to reopen the dialog.
As an alternative, you can use the CSS class borlabs-cookie-open-dialog-preferences. This class can be assigned to any HTML element. Once assigned, Borlabs Cookie automatically registers a click event for that element.
<span class="borlabs-cookie-open-dialog-preferences" data-borlabs-cookie-title="Lorem ipsum"></span>Consents
Grant Consent for a Service
window.BorlabsCookie.Consents.addConsent(serviceId: string, serviceGroupId: string): booleanCheck Consent for a Service
window.BorlabsCookie.Consents.hasConsent(serviceId: string, serviceGroupId?: string): booleanCheck Consent for a Service Group
window.BorlabsCookie.Consents.hasConsentForServiceGroup(serviceGroupId: string): booleanEvents
borlabs-cookie-after-init
This event is triggered after Borlabs Cookie has initialized all core components. It fires before it is determined whether the dialog should be displayed and before any opt-in code is executed or blocked content is unblocked.
window.addEventListener('borlabs-cookie-after-init', () => {});borlabs-cookie-before-content-unblocked[{key}]
This event is triggered before a Content Blocker is unblocked. The detail object contains the initiator property, which has either the value unblock-button or accept-service-button. Available since Borlabs Cookie version 3.4.
window.addEventListener('borlabs-cookie-before-content-unblocked[youtube-content-blocker]', function (e) {
console.log(`The clicked button (initiator) was: ${e.detail.initiator}`);
});borlabs-cookie-consent-saved
This event is triggered after a consent change has been made and the consent cookie has been updated. It is fired before blocked code is unblocked.
window.addEventListener('borlabs-cookie-consent-saved', () => {});borlabs-cookie-content-unblocked[{key}]
This event is triggered after a Content Blocker has been unblocked. The unblocked element is available in target. Available since Borlabs Cookie version 3.4.
window.addEventListener('borlabs-cookie-content-unblocked[youtube-content-blocker]', function (e) {
console.log("The content was unblocked", e.target);
});borlabs-cookie-dialog-closing
This event is triggered shortly before the dialog is closed. Available since Borlabs Cookie version 3.4.
window.addEventListener('borlabs-cookie-dialog-closing', () => {});borlabs-cookie-dialog-opening
This event is triggered shortly before the dialog is opened. Available since Borlabs Cookie version 3.4.
window.addEventListener('borlabs-cookie-dialog-opening', () => {});borlabs-cookie-handle-unblock
This event is triggered when the unblocking of blocked code is performed.
window.addEventListener('borlabs-cookie-handle-unblock', () => {});The borlabs-cookie-consent-saved event also executes the same unblocking routines that are triggered by borlabs-cookie-handle-unblock.
The borlabs-cookie-consent-saved event also executes the same unblocking routines that are triggered by borlabs-cookie-handle-unblock.
window.BorlabsCookie.Unblock.unblockServiceOptInCode();
window.BorlabsCookie.Unblock.unblockInlineCode('service-group');
window.BorlabsCookie.Unblock.unblockInlineCode('service');
window.BorlabsCookie.Unblock.unblockByContentBlockerServiceConsents();Logs
Logs in Chronological Order
window.BorlabsCookie.Log.logsChronicalLogs by Log Level
window.BorlabsCookie.Log.logsProviders
JavaScript Types
ProviderItem
ProviderItem {
address: string;
contentBlockerIds: string[];
cookieUrl: string;
description: string;
iabVendorId: number | null;
id: string;
name: string;
optOutUrl: string;
partners: string;
privacyUrl: string;
serviceIds: string[];
}Provider Information by Content Blocker ID
window.BorlabsCookie.Providers.findByContentBlockerId(contentBlockerId: string): ProviderItem | nullProvider Information by IAB TCF Vendor ID
window.BorlabsCookie.Providers.findByIabVendorId(iabVendorId: number): ProviderItem | nullProvider Information by Provider ID
window.BorlabsCookie.Providers.findByProviderId(providerId: string): ProviderItem | nullProvider Information by Service ID
window.BorlabsCookie.Providers.findByServiceId(serviceId: string): ProviderItemScript Blockers
Unblock by Script Blocker ID
window.BorlabsCookie.Unblock.unblockScriptBlockerId(scriptBlockerId: string): booleanServices
JavaScript Types
ServiceCookie
ServiceCookie {
description: string;
hostname: string;
lifetime: string;
name: string;
purpose: string;
type: string;
}ServiceItem
ServiceItem {
cookies: ServiceCookie[];
description: string;
hosts: ServiceHost[];
id: string;
name: string;
optInCode: string;
optOutCode: string;
options: ServiceOption[];
providerId: string;
serviceGroupId: string;
settings: Record;
}ServiceList
ServiceList = RecordServiceOption
ServiceOption {
name: string;
type: string;
}Service Information by Provider ID
window.BorlabsCookie.Services.findByProviderId(providerId: string): ServiceListService Information by Service ID
window.BorlabsCookie.Services.findByServiceId(serviceId: string): ServiceItemService Information by Service Group ID
window.BorlabsCookie.Services.findByServiceGroupId(serviceGroupId: string): ServiceListService Groups
JavaScript Types
ServiceGroupItem
ServiceGroupItem {
description: string;
id: string;
name: string;
preSelected: boolean;
serviceIds: string[];
}Service Group Information by Service Group ID
window.BorlabsCookie.ServiceGroups.findByServiceGroupId(serviceGroupId: string): ServiceGroupItemStyle Blocker
Unblock by Style Blocker ID
window.BorlabsCookie.Unblock.unblockStyleBlockerId(styleBlockerId: string): voidTools
cloneObject
Clones a JavaScript object without references.
window.BorlabsCookie.Tools.cloneObject(obj: any): anyinArray
JavaScript equivalent of PHP's in_array()-function.
window.BorlabsCookie.Tools.inArray(needle: number | string, haystack: Array)onExist
This method is intended for executing code that depends on external JavaScript loaded asynchronously during the unblocking process. To prevent errors caused by race conditions, this helper function checks whether the specified obj exists before executing the callback function passed to it.
window.BorlabsCookie.Tools.onExist(obj: any, callback: Function): void