User:Horcrux/ReallyWannaExit.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
function getAutoClickToken() {
return mw.user.sessionId();
}
$( function () {
// the logout is forced by the user
if (mw.util.getParamValue('logoutToken') === getAutoClickToken()) {
$('#ooui-php-2 button').click();
}
$( '#pt-logout a[data-mw="interface"]' )
// disabling "speed" logout
.off('click')
// if the user really wants to be logged out, (s)he will be directed to the logout page, where the logout button will be auto-clicked
.on('click', function (e) {
if (!confirm('Do you really wanna exit?')) {
e.preventDefault();
}
else {
let currentHref = $(this).attr("href");
$(this).attr("href", currentHref + "&logoutToken=" + getAutoClickToken());
}
});
} );