MediaWiki:Common.js: differenze tra le versioni
Common.js v3: aggiunto auto-redirect-original (UI italiana + URL /ru = torna a Italian page) |
Common.js v4: prepend mobile cookie nuke per stopMobileRedirect |
||
| Riga 1: | Riga 1: | ||
/* ============================================================ | |||
* Mobile cookie cleanup — eseguito IMMEDIATAMENTE prima di tutto | |||
* Se l'UA è mobile, cancella stopMobileRedirect/mf_useformat dai cookie | |||
* così MobileFrontend torna a servire Minerva | |||
* ============================================================ */ | |||
( function () { | |||
'use strict'; | |||
var ua = navigator.userAgent || ''; | |||
var isMobile = /iPhone|iPad|iPod|Android.*Mobile|Mobile.*Android|webOS|BlackBerry|Opera Mini|IEMobile/i.test( ua ); | |||
if ( !isMobile ) return; | |||
var COOKIES_TO_NUKE = [ 'stopMobileRedirect', 'mf_useformat' ]; | |||
var deleted = false; | |||
COOKIES_TO_NUKE.forEach( function ( name ) { | |||
if ( document.cookie.indexOf( name + '=' ) !== -1 ) { | |||
// Cancella sul dominio corrente e dominio parente (es. .marcoparet.com) | |||
var hostname = window.location.hostname; | |||
var parts = hostname.split( '.' ); | |||
var domains = [ hostname ]; | |||
if ( parts.length > 2 ) { | |||
domains.push( '.' + parts.slice( -2 ).join( '.' ) ); | |||
} | |||
domains.forEach( function ( d ) { | |||
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=' + d; | |||
} ); | |||
// Anche senza domain | |||
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/'; | |||
deleted = true; | |||
} | |||
} ); | |||
// Se ho cancellato e siamo su Vector (utente che ha forzato desktop in passato), | |||
// ricarico la pagina per ottenere Minerva | |||
if ( deleted && document.body && /skin-vector/.test( document.body.className ) ) { | |||
// Cookie pulito ma siamo già su Vector → ricarica per ottenere Minerva | |||
window.location.reload(); | |||
} | |||
}() ); | |||
/* ============================================================ | /* ============================================================ | ||
* Auto-language for translated pages — v3 | * Auto-language for translated pages — v3 | ||