14 lines
865 B
JavaScript
14 lines
865 B
JavaScript
// Preserve old bookmarked desk fragments after Home becomes the Writer entry point.
|
|
// Use only server-generated, authorised book-scope URLs; never copy a chapter or native selection.
|
|
(() => {
|
|
const home=document.querySelector('[data-writer-destination="Home"]');
|
|
if(!home)return;
|
|
const restore=()=>{
|
|
const hash=location.hash;
|
|
const path=hash==='#workspaces'?home.dataset.writerQueuesUrl:hash==='#display-setup'?home.dataset.writerLegacyUrl:
|
|
['#working-focus','#working-objective','#objective-setup'].includes(hash)?home.dataset.writerWriteUrl:null;
|
|
if(path){const target=new URL(path,location.origin);if(hash!=='#working-focus'&&path===home.dataset.writerWriteUrl)target.searchParams.set('setup','true');target.hash=hash;location.replace(target.pathname+target.search+target.hash);}
|
|
};
|
|
window.addEventListener('hashchange',restore);restore();
|
|
})();
|