Search code examples
javascripthtmltwitter

Is there a way to notify whenever tweet list is updated in twitter embedded widget?


I am using twitter embed widget on my website. It posts twitter timeline on my page. I want to toast whenever the tweet list gets updated.

<a class="twitter-timeline" data-width="100%" data-height="382" data-theme="light" data-link-color="#2B7BB9" data-chrome="nofooter " href="https://twitter.com/Arushi_Rajput?ref_src=twsrc%5Etfw">Tweets by Arushi_Rajput</a>

<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

List gets updated itself through twitter widget so if I post a tweet on my timeline it automatically updates the list after 30 seconds on my page.

I want to toast whenever I receive a new tweet.


Solution

  •  window.onload= function(){
        var x = document.getElementById("twitter-widget-0");
        var y = (x.contentWindow || x.contentDocument);
        if (y.document)y = y.document;
        y.getElementsByClassName("timeline-TweetList")[0].addEventListener("DOMNodeInserted", function(event) {
            alert("New Tweet Received!!");
        });
      };
    

    It has been some time while I posted this question. This is the code that worked!