MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / confirmPopState

Function confirmPopState

src/common/router.js:53–61  ·  view source on GitHub ↗
(hash)

Source from the content-addressed store, hash-verified

51
52export function getUnloadSentry(onConfirm, onCancel) {
53 async function confirmPopState(hash) {
54 if (await showConfirmation(i18n('confirmNotSaved'))) {
55 // popstate cannot be prevented so we pin current `route` and display a confirmation
56 setRoute(hash, false, true);
57 onConfirm?.();
58 } else {
59 onCancel?.();
60 }
61 }
62 function toggle(state) {
63 const onOff = `${state ? 'add' : 'remove'}EventListener`;
64 global[onOff]('beforeunload', onUnload);

Callers

nothing calls this directly

Calls 3

showConfirmationFunction · 0.90
setRouteFunction · 0.85
onCancelFunction · 0.85

Tested by

no test coverage detected