/* SAN AVELIO - PROFILE EDIT ACCESS v6 VIEW FIX Fixes native "View" route: plain profile.php?id=... returns to custom dossier. All management routes remain native. 12993 / 70119 / HTML-bottom untouched. */ (function(){ 'use strict'; if(!/\/profile\.php$/i.test(location.pathname)) return; var q=new URLSearchParams(location.search); var viewedId=q.get('id')||''; function myId(){ var a=document.querySelector('#navprofile a[href*="profile.php"]'); if(!a)return ''; try{return new URL(a.href,location.href).searchParams.get('id')||''}catch(e){return ''} } function isManagementUrl(u){ try{ var x=new URL(u,location.href); if(!/\/profile\.php$/i.test(x.pathname))return false; var p=x.searchParams; return p.has('section')||p.has('action')||p.has('edit')||p.has('p')|| p.has('page')||p.has('mode')||p.has('form'); }catch(e){return false} } function isPlainViewUrl(u){ try{ var x=new URL(u,location.href); if(!/\/profile\.php$/i.test(x.pathname))return false; return !isManagementUrl(x.href); }catch(e){return false} } function style(){ if(document.getElementById('sa-pe-v6'))return; var s=document.createElement('style');s.id='sa-pe-v6';s.textContent=` #sa-dossier-clean .sa-profile-edit-access{display:inline-flex;align-items:center;justify-content:center;margin-top:18px;padding:11px 16px;border:1px solid rgba(205,164,91,.58);background:linear-gradient(180deg,rgba(196,147,72,.12),rgba(196,147,72,.035));color:#e5c17e!important;text-decoration:none!important;font:700 8px/1 Arial,sans-serif;letter-spacing:.18em;cursor:pointer} #sa-dossier-clean .sa-profile-edit-access:hover{border-color:#e1ba72;background:rgba(196,147,72,.16);color:#ffe0a2!important} html.sa-profile-native #pun-main{box-sizing:border-box!important;max-width:1120px!important;margin:18px auto 46px!important;padding:28px 30px 34px!important;background:radial-gradient(circle at 100% 0,rgba(192,145,72,.08),transparent 30%),linear-gradient(180deg,#f7f0e4,#eee1ca)!important;border:1px solid rgba(161,119,60,.52)!important;box-shadow:0 28px 80px rgba(0,20,27,.25),inset 0 0 0 7px rgba(255,250,239,.42)!important;color:#173940!important;position:relative!important} html.sa-profile-native #pun-main:before{content:'SAN AVELIO / ARCHIVIO PERSONALE';display:block!important;margin:0 0 18px!important;padding:0 0 12px!important;border-bottom:1px solid rgba(157,116,59,.30)!important;color:#9b7040!important;font:700 8px/1 Arial,sans-serif!important;letter-spacing:.25em!important} html.sa-profile-native #pun-main h1,html.sa-profile-native #pun-main h2,html.sa-profile-native #pun-main h3{color:#123943!important;font-family:Georgia,serif!important} html.sa-profile-native #pun-main h1{margin:0 0 18px!important;padding:0 0 13px!important;border-bottom:1px solid rgba(153,112,57,.28)!important;font-size:26px!important;font-weight:400!important} html.sa-profile-native #pun-main .container,html.sa-profile-native #pun-main .formal{background:transparent!important} html.sa-profile-native #pun-main fieldset{margin:18px 0!important;padding:20px 22px!important;border:1px solid rgba(151,112,59,.30)!important;background:rgba(255,250,239,.26)!important;box-shadow:inset 3px 0 0 rgba(173,128,65,.16)!important} html.sa-profile-native #pun-main legend{padding:0 10px!important;color:#8d6535!important;font:700 9px Arial,sans-serif!important;letter-spacing:.15em!important;text-transform:uppercase!important} html.sa-profile-native #pun-main a{color:#9b563b!important} html.sa-profile-native #pun-main ul{display:grid!important;grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:7px 10px!important;margin:14px 0 22px!important;padding:0!important;list-style:none!important} html.sa-profile-native #pun-main ul li{margin:0!important;padding:0!important} html.sa-profile-native #pun-main ul li a{display:block!important;padding:9px 11px!important;border:1px solid rgba(154,115,61,.22)!important;background:rgba(255,250,239,.28)!important;text-decoration:none!important;font:700 9px/1.2 Arial,sans-serif!important;letter-spacing:.06em!important;transition:.16s ease!important} html.sa-profile-native #pun-main ul li a:hover{background:rgba(176,128,62,.10)!important;border-color:rgba(154,115,61,.46)!important} html.sa-profile-native #pun-main input[type=text],html.sa-profile-native #pun-main input[type=password],html.sa-profile-native #pun-main input[type=email],html.sa-profile-native #pun-main textarea,html.sa-profile-native #pun-main select{box-sizing:border-box!important;max-width:100%!important;border:1px solid rgba(115,87,49,.38)!important;background:#fffaf0!important;color:#17363d!important;padding:9px 10px!important} html.sa-profile-native #pun-main input[type=submit],html.sa-profile-native #pun-main button{border:1px solid #a17a43!important;background:#123b43!important;color:#f0d39c!important;padding:10px 16px!important;cursor:pointer!important} html.sa-profile-native #pun-main .formsubmit{margin-top:18px!important;padding-top:16px!important;border-top:1px solid rgba(151,112,59,.25)!important} @media(max-width:760px){html.sa-profile-native #pun-main{padding:20px 16px 26px!important;margin:8px!important}html.sa-profile-native #pun-main ul{grid-template-columns:1fr!important}} `;document.head.appendChild(s) } function restoreNative(){ var main=document.getElementById('pun-main');if(!main)return false; var d=document.getElementById('sa-dossier-clean');if(d)d.remove(); Array.prototype.forEach.call(main.children,function(el){ if(el.id==='sa-dossier-clean'){el.remove();return} if(el.style&&el.style.display==='none')el.style.removeProperty('display'); }); document.documentElement.classList.add('sa-profile-native');style();return true } function cleanNativeClass(){ document.documentElement.classList.remove('sa-profile-native'); } function button(){ var d=document.getElementById('sa-dossier-clean'); if(!d||d.querySelector('.sa-profile-edit-access'))return; if(!viewedId||myId()!==viewedId)return; var host=d.querySelector('.identity')||d;style(); var a=document.createElement('a');a.className='sa-profile-edit-access'; a.href='/profile.php?section=fields&id='+encodeURIComponent(viewedId); a.textContent='\u0420\u0415\u0414\u0410\u041a\u0422\u0418\u0420\u041e\u0412\u0410\u0422\u042c \u041f\u0420\u041e\u0424\u0418\u041b\u042c'; host.appendChild(a) } function guardLinks(){ document.addEventListener('click',function(e){ var a=e.target&&e.target.closest?e.target.closest('a[href]'):null;if(!a)return; if(isManagementUrl(a.href)){try{sessionStorage.setItem('sa-profile-native-next','1')}catch(_){}} else if(isPlainViewUrl(a.href)){try{sessionStorage.removeItem('sa-profile-native-next')}catch(_){}} },true) } var scrolled=false; function run(){ if(isManagementUrl(location.href)){ if(restoreNative()&&!scrolled){scrolled=true;setTimeout(function(){var m=document.getElementById('pun-main');if(m){var y=m.getBoundingClientRect().top+window.pageYOffset-12;window.scrollTo(0,Math.max(0,y))}},250)} }else{ cleanNativeClass(); button(); } } var mo=new MutationObserver(run); function start(){guardLinks();run();mo.observe(document.documentElement,{subtree:true,childList:true,attributes:true,attributeFilter:['style']});setTimeout(run,100);setTimeout(run,350);setTimeout(run,800);setTimeout(run,1600)} if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',start,{once:true});else start(); })();