Skip to content

Instantly share code, notes, and snippets.

@salsalabs
salsalabs / delete-payment-option.html
Created November 13, 2020 19:11
Wait for the payment option block to appear then delete it. Solves an issue with a misconfigured PayPal account.
<!-- SalsaStaff 365924: BEGIN delete the payment option fieldset that holds the PayPal payment option. -->
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", () => {
// select the target node
var target = document.querySelector("#salsa");
// create an observer instance
var observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
console.log(mutation.type);
});
@salsalabs
salsalabs / welcome_back_country_fill.html
Created August 3, 2020 22:14
Supply/fill Country field on the Welcome Back pages. We need this because the Welcome Back page does not cache Country (known issue).
<?
// SalsaScript to check if the supporter is logged in. If so,
// it deposits the script that populates/appends the Country field.
(function() {
var country = null;
if (Supporter == null) { return; }
country = Supporter.get("Country");
country = (country == null) ? "US" : country;
?>
<!-- BEGIN Supply/fill country field on Welcome Back pages. -->
@salsalabs
salsalabs / event_remove_calendar_buttions.html
Created July 21, 2020 21:54
Script to remove the calendar buttons from an event.
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
var e = document.querySelector("#calendarButtons");
if (e != null) {
e.style.display = "none";
}
})
</script>
@salsalabs
salsalabs / event_hide_submit_button.html
Last active July 20, 2020 22:05
Script to hide the submit button on an event. Input fields will still be live -- there just won't be a way to submit them.
<!-- BEGIN Hide submit button on an event. -->
<script type="text/javascript">
$(document).ready(function () {
var e = document.querySelector("#submitAddAttendee");
if (e != null) {
e.style.display = "none";
}
});
</script>
<!-- END Hide Submit button on an event. -->
@salsalabs
salsalabs / wrap_script_for_thank_you_page.js
Created June 22, 2020 19:30
Put a wrapper around a script so that it only runs on thank you pages with a donation_KEY and an amount.
// Put this text on a new line just after the <script> tag (https://prnt.sc/t4j44d).
var isThankYouPage = document.location.href.indexOf("thank_you") != -1;
var hasDonationKEY = /donate_page_KEY=\d+/.test(document.location.href);
var hasAmount = /amount=\d+/.test(document.location.href);
if (isThankYouPage && hasDonationKey && hasAmount) {
// Put this text just before the </script> tag (https://prnt.sc/t4j4il).
}
@salsalabs
salsalabs / change_country_names.html
Last active June 9, 2020 21:52
Change displayed names for selected countries.
<!-- BEGIN Change displayed names for selected countries. -->
<script type="text/javascript">
(function() {
// This object maps country abbreviations to text.
// - The keys are ISO-3166 Alpha 2 abbreviations for countries.
// - The values are the countries names to display.
// You can find the abbreviations by viewing the HTML source
// of any page that has a country field.
countries = {
"LY": "Libya",
@salsalabs
salsalabs / move_first_name_before_last_name.html
Created May 21, 2020 15:02
Demonstration script for moving the first name in a donation page before the last name.
<script type="text/javascript">
// Script to move the last name before the first name on a donation page.
// Only run this script on donation pages. This should work for both
// regular pages and pages with a Salsa shortcut.
if (window.location.href.indexOf('/salsa/donation/') != -1) {
// Wait for the page to be loaded.
$(document).ready(function() {
@salsalabs
salsalabs / secure_actions.html
Last active May 6, 2020 14:14
Script to find public-facing pages with HTTP (non-secure) URLs and change the URL to HTTPS (secure).
<!-- BEGIN Change non-secure action URLs to secure. -->
<script type="text/javascript">
if (/^http:/.test(window.location.href)) {
window.location.href = window.location.href.replace('http', 'https');
}
</script>
<!-- END Change non-secure action URLs to secure. -->
@salsalabs
salsalabs / hide_petition_signatures.html
Last active February 4, 2020 15:40
Provide a way to hide or show the Location information on a Salsa Classic petition that displays signatures.
<!-- BEGIN Script to remove the city and state from petitions.
To remove cities and states from the petition, add the following HTML to the petition header.
<div style="display: none;" id="remove-petition-cities-and-states"></div>
To restore cities and states to a petition, remove the HTML.
-->
<script type="text/javascript">
(function($) {
$(function() {
var e = $('#remove-petition-cities-and-states');
if (e.length == 0) {
@salsalabs
salsalabs / event_change_optional_group_header.html
Last active January 22, 2020 22:30
Change the description for the optional groups on an Classic event page.
<script type="text/javascript">
(function($) {
$(document).ready(function() {
if (window.location.href.indexOf('event_KEY=89503') != -1) {
var e = $('#regForm2 > strong:nth-child(21)');
if (e.length > 0) {
e.html('Add me to the email subscriptions below to be notified of important alerts:');
}
}
});