Using code to switch from classic to modern view in SharePoint, need to tweak the script so it doesn’t update URL

I’m using this code to below and trying to keep the url from changing.

<A HREF="javascript:(function(){document.cookie = `splnu=0;domain=${window.location.hostname};`; location.href = `${_spPageContextInfo.webServerRelativeUrl}/_layouts/15/viewlsts.aspx`;})();">Classic</A>