Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Function to move the Afterpay on-site message to the target div
- function moveAfterpayMessage() {
- var afterpayMessage = document.querySelector('.afterpay-placement');
- var targetDiv = document.querySelector('#afterpay');
- if (afterpayMessage && targetDiv) {
- targetDiv.appendChild(afterpayMessage);
- }
- }
- // Create a MutationObserver to watch for changes in the DOM
- var observer = new MutationObserver(function(mutationsList) {
- for (var mutation of mutationsList) {
- if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
- // Check if the Afterpay on-site message is added to the DOM
- var addedNodes = Array.from(mutation.addedNodes);
- var afterpayMessageAdded = addedNodes.some(function(node) {
- return node.classList && node.classList.contains('afterpay-placement');
- });
- if (afterpayMessageAdded) {
- moveAfterpayMessage();
- }
- }
- }
- });
- // Start observing changes in the DOM
- observer.observe(document.body, { childList: true, subtree: true });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement