If you want to remove the browser's Back button functionality in Sugarcane, to prevent the player from rewinding or undoing moves, here is some script code that can do that.
If you are not using Transition CSS, then include this code:
History.prototype.save=function(c){var a="";for(var b=this.history.length-1;b>=0; b--){if((this.history[ b].passage)&&(this.history[ b].passage.id)){a+=this.history[ b].passage.id.toString(36)+"."; }}this.history[0].hash="#"+a.substr(0,a.length-1);if(this.hash){return"";}this.hash=this.history[0].hash; return this.hash;};History.prototype.restart=function(){window.location.reload(); };
If you are using Transition CSS, then do this:
Replace the Transition CSS Sugarcane code with the Transition CSS Jonah code.
For either of those options, also include this code to allow the <<back>> macro, the Restart menu and the Rewind menu to work:
History.prototype.restart=function(){window.location.reload();};macros["return"]=macros.back={handler:function(a,b,e){ var d="";var steps=1;if(e[0]){if(e[1]=="steps"){if(isNaN(e[0])){throwError(a,"parameter before 'steps' must be a number."); return;}else{if(e[0]<state.history.length){d=state.history[e[0]].passage.title;steps=e[0]; }}}else{if(tale.get(e[0]).id==undefined){throwError(a,"The "+e[0]+" passage does not exist"); return;}for(var c=0;c<state.history.length;c++){if(state.history[c].passage.title==e[0]){d=e[0]; steps=c;break;}}}}else{d=state.history[1].passage.title;}if(d==undefined){return; }else{el=document.createElement("a");el.className="return";el.onclick=function(){if(b=="back"){while(steps>=0){if(state.history.length>1){state.history.shift(); }steps--;}}state.display(d);};el.href="javascript:void(0)";el.innerHTML="<b>«</b> "+b[0].toUpperCase()+b.slice(1); a.appendChild(el);}}};Interface.buildSnapback=function(){var c=false;removeChildren($("snapbackMenu")); for(var a=state.history.length-1;a>=0;a--){if(state.history[a].passage&&state.history[a].passage.tags.indexOf("bookmark")!=-1){var b=document.createElement("div"); b.pos=a;b.onclick=function(){var p=this.pos;var n=state.history[p].passage.title; while(p>=0){if(state.history.length>1){state.history.shift();}p--;}state.display(n); };b.innerHTML=state.history[a].passage.excerpt();$("snapbackMenu").appendChild(b); c=true;}}if(!c){var b=document.createElement("div");b.innerHTML="<i>No passages available</i>"; $("snapbackMenu").appendChild(b);}};
This will prevent previously visited passages from appearing in the player's browser history.
Version history: