Warns user before going back when browsing on your Synology DSM NAS
当前为
// ==UserScript==
// @name Warn/Prevent Back button for Synology DSM
// @version 1.2
// @grant none
// @license MIT
// @match https://192.168.1.106:5001/*
// @description Warns user before going back when browsing on your Synology DSM NAS
// @namespace https://greasyfork.org/users/1476593
// ==/UserScript==
(function() {
'use strict';
// Push a dummy state to capture back button
window.addEventListener('load', function() {
history.pushState({page: 1}, '', '');
});
// Capture popstate (back/forward)
window.addEventListener('popstate', function(e) {
if (confirm('Are you sure you want to leave this page?')) {
// User confirmed - allow navigation
history.go(-1);
} else {
// User cancelled - stay here
history.pushState({page: 1}, '', '');
}
});
// Block other navigation methods
window.onbeforeunload = function() {
return 'Are you sure you want to leave?';
};
})();