How can I override MS default overlay text like "Plan successfully added" per subpage using CSS? Answered

Post author
Mikkel Åstrøm

Hey guys. Has anyone been able to change the text of the MS default overlay UI like "Plan successfully added" for individual subpages using css?

Comments

3 comments

  • Comment author
    Julian Galluzzo

    I have with JavaScript, I dont think its possible with CSS

    I cannot for the life of me remember where I used that but I can remember how i did it!

    <script>
    document.addEventListener("DOMContentLoaded", function() {
        setTimeout(function() {
            // Select the node that will be observed for mutations
            var targetNode = document.body; // body is chosen here for widest coverage
    
            // Options for the observer (which mutations to observe)
            const config = { attributes: false, childList: true, subtree: true };
    
            // Callback function to execute when mutations are observed
            const callback = function(mutationsList, observer) {
                for(let mutation of mutationsList) {
                    if (mutation.type === 'childList') {
                        var messageDiv = document.getElementById("ms-message");
                        if (messageDiv) {
                            messageDiv.textContent = "WRITE YOUR NEW TEXT HERE";
                            observer.disconnect();  // Disconnect observer after changes are made
                            break;
                        }
                    }
                }
            };
    
            // Create an observer instance linked to the callback function
            const observer = new MutationObserver(callback);
    
            // Start observing the target node for configured mutations
            observer.observe(targetNode, config);
        }, 1500);
    });
    </script>
    0
  • Comment author
    Mikkel Åstrøm

    Appreciate it! Thanks for taking the time, I really appreciate it. This worked immediately., however, do you know if there's a way to separate plan added and plan removed?

    So my objective here is to personalize a page that lets you follow a product (using free plans). There's a CMS based feed for followed products.

    So basically I need to override the next "You're now following "
    "You're no longer following "

    0
  • Comment author
    Julian Galluzzo

    ohhhhh 🤔 for that I'm not sure yet, i think i may work on a solution though

    0

Please sign in to leave a comment.