detect change url

Run Settings
LanguageJavaScript
Language Version
Run Command
function listenForURLChange(cb) { let body = document.getElementsByTagName("body")[0]; document.addEventListener('onurlchange', (e) => { cb(e.detail.path); }); let html = ` let pushState = window.history.pushState; window.history.pushState = function(state) { document.dispatchEvent(new CustomEvent('onurlchange', { detail: state })); return pushState.apply(window.history, arguments); };`; let patch = document.createElement("script"); patch.type = 'text/javascript'; patch.innerHTML = html; body.appendChild(patch); // Also we'll catch "back" button. window.onpopstate = (e) => { cb(e.state.path) }; }
Editor Settings
Theme
Key bindings
Full width
Lines