Last active
December 19, 2018 20:45
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!