mirror of
https://github.com/StarCitizenTools/mediawiki-skins-Citizen.git
synced 2024-11-14 10:04:56 +00:00
feat: only set as session cookie if no conscent
This commit is contained in:
parent
63da182147
commit
b850797b4d
|
@ -7,11 +7,25 @@
|
|||
var prefersColorSchemeDarkQuery,
|
||||
userTheme,
|
||||
theme,
|
||||
setCookieChangeTheme;
|
||||
setCookieChangeTheme,
|
||||
hasCookieConscent,
|
||||
cookieOptions;
|
||||
|
||||
setCookieChangeTheme = function ( themeName ) {
|
||||
try {
|
||||
window.mw.cookie.set( 'skin-citizen-theme', themeName, { sameSite: 'Strict' } );
|
||||
cookieOptions = {};
|
||||
// The cookie is only used on the site
|
||||
cookieOptions.sameSite = 'Strict';
|
||||
// Check if Extension:CookieWarning is enabled
|
||||
if ( window.mw.loader.getState( 'ext.CookieWarning' ) ) {
|
||||
// Set the cookie as a session cookie if no conscent is given
|
||||
hasCookieConscent = window.mw.cookie.get( 'cookiewarning_dismissed' ) === true ||
|
||||
window.mw.user.options.get( 'cookiewarning_dismissed' ) === 1;
|
||||
if ( !hasCookieConscent ) {
|
||||
cookieOptions.expires = null;
|
||||
}
|
||||
}
|
||||
window.mw.cookie.set( 'skin-citizen-theme', themeName, cookieOptions );
|
||||
} catch ( e ) {
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue