Skip to content

Instantly share code, notes, and snippets.

@salsalabs
Created November 13, 2020 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salsalabs/ff5187399d88c88ff837f191468a8103 to your computer and use it in GitHub Desktop.
Save salsalabs/ff5187399d88c88ff837f191468a8103 to your computer and use it in GitHub Desktop.
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);
});
// Remove the payment type if it has been added.
var unwanted = document.querySelector('fieldset.payment-type');
if (unwanted != null) {
unwanted.parentNode.removeChild(unwanted);
observer.disconnect();
}
});
// configuration of the observer:
var config = { childList: true }
// pass in the target node, as well as the observer options
observer.observe(target, config);
});
</script>
<!-- SalsaStaff 365924: END delete the payment option fieldset that holds the PayPal payment option. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment