Skip to content

Instantly share code, notes, and snippets.

@salsalabs
Last active December 19, 2018 20:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salsalabs/d2b48ead0671ef28f19a to your computer and use it in GitHub Desktop.
Save salsalabs/d2b48ead0671ef28f19a to your computer and use it in GitHub Desktop.
A script to disable Salsa's welcome back message. The supporter is logged out of the current page and returned to the same page. A flag is placed into session storage that this script doesn't loop forever. The script ignores pages that are part of a workflow or that have a displayed error.
<script type="text/javascript">
// Automatically log supporters out of Salsa pages, effectively disabling the
// Welcome Back Message. See https://help.salsalabs.com/hc/en-us/articles/223344487
// This script will not run if Salsa's returned an error.
if (document.querySelector('.error') == null) {
if (typeof window.sessionStorage.redirected == "string") {
delete window.sessionStorage.redirected;
} else {
var notThese = ['event/common.+checkout.sjs', 'guestReg', 'receipt.sjs',
'shop/index.jsp', 'shop/viewCart.jsp', 'shop/checkOut.jsp', 'shop/item.jsp',
'Tellafriend.sjs', 'login.jsp'
];
var notTester = function (n) {
return RegExp(n).test(window.location.href);
}
if (!notThese.some(notTester)) {
window.sessionStorage.redirected = 'true';
window.location = "/dia/logout.jsp?killorg=" + <?= salsa.organization_KEY ?>;
}
}
}
</script>
@salsalabs
Copy link
Author

salsalabs commented Mar 7, 2017

Hey, all! This version of the Welcome Back disabler doesn't need "&okay=true". It also works correctly on donation pages that have user or submission errors. Replace your current script with this one! Be happier!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment