0

I am using a google chrome extension called CJS which allows you to run javascript code on websites.

I have it injecting jQuery, and then running this code on twitter's stream

setInterval(()=>{
  jQuery('article').each(index=>{
    console.log( index + ": " + jQuery( this ).text() );
  })
}, 1000)

The ultimate goal is to hide tweets that are retweets.

Twitter does have a DOM article wrapped around each of the tweets, so the plan was to get those, iterate over them, and if the text includes "retweet", hide the article.

It is able to iterate over them, and in the console it just shows the indexes of the items, but the text of jQuery(this) ends up being an empty string, even when the content is fully loaded.

RobKohr
  • 6,611
  • 7
  • 48
  • 69

1 Answers1

0

The issue is with using a fat arrow function (index)=>{... instead of function(index){... in the each section. This means that the this referred to the scope of the calling function rather than the scope for the jQuery dom element.

RobKohr
  • 6,611
  • 7
  • 48
  • 69