1- function getCookie ( name ) {
2- const value = `; ${ document . cookie } ` ;
3- const parts = value . split ( `; ${ name } =` ) ;
4- if ( parts . length === 2 ) return parts . pop ( ) . split ( ';' ) . shift ( ) ;
5- }
6-
71const showCookieBanner = ( ) => {
8- // Check both localStorage and cookie for consent
9- const localStorageConsent = localStorage . getItem ( 'deepl_cookie_consent' ) ;
10- const cookieConsent = getCookie ( 'cookie_consent' ) ;
2+ // Check localStorage for consent
3+ const consent = localStorage . getItem ( 'deepl_cookie_consent' ) ;
114
12- if ( localStorageConsent === 'accepted' || cookieConsent === 'true' ) return ;
5+ // Only hide banner if user has explicitly accepted or rejected
6+ if ( consent === 'accepted' || consent === 'rejected' ) return ;
137
148 const banner = document . createElement ( 'div' ) ;
159 banner . id = 'cookie-banner' ;
@@ -32,23 +26,16 @@ const showCookieBanner = () => {
3226
3327 const acceptBtn = document . getElementById ( 'cookie-accept' ) ;
3428 const rejectBtn = document . getElementById ( 'cookie-reject' ) ;
35- const ONE_YEAR_SECONDS = 60 * 60 * 24 * 365 ;
3629
3730 acceptBtn . onclick = function ( ) {
38- // Set localStorage for Mintlify telemetry integration
3931 localStorage . setItem ( 'deepl_cookie_consent' , 'accepted' ) ;
40- // Also set cookie for backward compatibility
41- document . cookie = 'cookie_consent=true; path=/; max-age=' + ONE_YEAR_SECONDS ;
4232 banner . remove ( ) ;
4333 // Reload to enable telemetry
4434 window . location . reload ( ) ;
4535 } ;
4636
4737 rejectBtn . onclick = function ( ) {
48- // Set localStorage to rejected state
4938 localStorage . setItem ( 'deepl_cookie_consent' , 'rejected' ) ;
50- // Also set cookie for backward compatibility
51- document . cookie = 'cookie_consent=false; path=/; max-age=' + ONE_YEAR_SECONDS ;
5239 banner . remove ( ) ;
5340 } ;
5441}
0 commit comments