Skip to content

Instantly share code, notes, and snippets.

@thraizz
Created May 28, 2024 11:12
Show Gist options
  • Save thraizz/f5c9f1bfc9d0846704d6eabbc1489f66 to your computer and use it in GitHub Desktop.
Save thraizz/f5c9f1bfc9d0846704d6eabbc1489f66 to your computer and use it in GitHub Desktop.
Type-safe cookiebot renewal
type Cookiebot = {
name: string;
consented: boolean;
declined: boolean;
changed: boolean;
hasResponse: boolean;
consentID: string;
consent: object;
isOutsideEU: boolean;
isOutOfRegion: boolean;
host: string;
domain: string;
currentPath: string;
doNotTrack: boolean;
consentLevel: string;
isRenewal: boolean;
forceShow: boolean;
dialog: object;
responseMode: string;
serial: string;
scriptId: string;
scriptElement: object;
whitelist: object;
cookieList: object;
pathlist: object;
userIsInPath: boolean;
cookieEnabled: boolean;
versionChecked: boolean;
versionRequested: boolean;
version: number;
latestVersion: number;
isNewVersion: boolean;
CDN: string;
source: string;
retryCounter: number;
frameRetryCounter: number;
bulkConsentFrameRetryCounter: number;
setOnloadFrameRetryCounter: number;
optOutLifetime: number;
consentModeDisabled: boolean;
consentModeDataRedaction: string;
consentLifetime: number;
framework: string;
hasFramework: boolean;
frameworkBlocked: boolean;
frameworkLoaded: boolean;
iframeReady: boolean;
iframe: object;
bulkconsent: object;
bulkresetdomains: object;
bulkconsentsubmitted: boolean;
isbulkrenewal: boolean;
handleCcpaOptinInFrontend: boolean;
wipe: object;
consentUTC: object;
IABConsentString: string;
GACMConsentString: string;
dataLayerName: string;
loaded: boolean;
autoblock: boolean;
mutationObserver: object;
mutationCounter: number;
mutationFallback: boolean;
mutationFallbackDocAttributes: object;
mutationHandlerFallbackCharsetLoaded: boolean;
mutationAppName: string;
mutationEventListeners: object;
mutationOnloadEventListeners: object;
mutateEventListeners: boolean;
mutationHandlerFirstScript: object;
postPonedMutations: object;
nonAsyncMutations: object;
deferMutations: object;
geoRegions: object;
userCountry: string;
userCulture: string;
userCultureOverride: object;
windowOnloadTriggered: boolean;
botDetectionDisabled: boolean;
regulations: object;
regulationRegions: object;
commonTrackers: object;
configuration: object;
inlineConfiguration: object;
widget: object;
bulkConsentEnabled: boolean;
computedConfiguration: object;
$assign: Function;
init: Function;
initConsent: Function;
signalWindowLoad: Function;
registerGeoRegions: Function;
submitImpliedConsent: Function;
cbonloadevent: Function;
processLinkClickCounter: number;
performanceEntriesCounter: number;
processLinkClick: Function;
loadCDNiFrame: Function;
readBulkConsent: Function;
handleBulkConsentIframeMessage: Function;
checkForBulkConsent: Function;
deleteConsentCookie: Function;
resetBulkDomains: Function;
removeBulkReset: Function;
removeCurrentDomainBulkReset: Function;
registerBulkConsent: Function;
updateBulkStorage: Function;
signalConsentFramework: Function;
cloneScriptTag: Function;
runScripts: Function;
RunScriptTags: Function;
RunSrcTags: Function;
applyDisplay: Function;
hideElement: Function;
displayElement: Function;
registerDisplayState: Function;
hasClass: Function;
addClass: Function;
removeClass: Function;
setOnload: Function;
triggerOnloadEvents: Function;
getGTMDataLayer: Function;
triggerGTMEvents: Function;
signalGoogleConsentAPI: Function;
pushGoogleConsent: Function;
show: Function;
hide: Function;
renew: Function;
getURLParam: Function;
getDomainUrlParam: Function;
process: Function;
getCookie: Function;
setCookie: Function;
removeCookies: Function;
getRootDomain: Function;
resetCookies: Function;
removeCookieHTTP: Function;
removeCookieLocalStorage: Function;
withdraw: Function;
setOutOfRegion: Function;
isSpider: Function;
getScript: Function;
fetchJsonData: Function;
loadIframe: Function;
setDNTState: Function;
setHeaderStyles: Function;
submitConsent: Function;
submitCustomConsent: Function;
isGUID: Function;
hashCode: Function;
tagHash: Function;
initMutationObserver: Function;
overrideEventListeners: Function;
isInternalEventListener: Function;
stopOverrideEventListeners: Function;
OverrideEventListenersOnloadFired: object;
OverrideEventListenersOnloadToFire: object;
applyOverrideEventListeners: Function;
cloneEventListeners: Function;
downloadConfiguration: Function;
initWidget: Function;
logWidgetAttributeWarning: Function;
mutationHandler: Function;
preloadMutationScript: Function;
processMutation: Function;
isCookiebotNode: Function;
isCookiebotCoreNode: Function;
postponeMutation: Function;
processPostPonedMutations: Function;
dequeueNonAsyncScripts: Function;
getTagCookieCategories: Function;
cookieCategoriesFromNumberArray: Function;
stopMutationObserver: Function;
mutationHandlerFallback: Function;
mutationHandlerFallbackInit: Function;
fallbackScriptNodes: object;
fallbackDeferNodes: object;
startJQueryHold: Function;
endJQueryHold: Function;
loadFallbackScriptNodes: Function;
mutationHandlerFallbackMarkupTag: Function;
resolveURL: Function;
getHostnameFromURL: Function;
updateRegulations: Function;
signalConsentReady: Function;
};
declare global {
interface Window {
Cookiebot: Cookiebot;
}
}
export const renewCookiebot = () => {
if (window.Cookiebot) {
window.Cookiebot.renew();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment