drewrwilson / SomeRichAsshole

Browser add-on that replaces "Donald Trump" with "Some Rich Asshole"
http://SomeRichAsshole.com
MIT License
17 stars 9 forks source link

Still not replacing all instances of Donald Trump #16

Open gopperman opened 9 years ago

gopperman commented 9 years ago

NY Times:

screen shot 2015-09-16 at 11 02 27 am
drewrwilson commented 9 years ago

Wait, that looks like it's working to me

gopperman commented 9 years ago

Link: http://www.nytimes.com/2015/09/16/us/politics/gop-support-for-donald-trump-rising-as-ben-carson-gains-poll-finds.html

gopperman commented 9 years ago

(PS: Look at the article feed up top for the bug)

drewrwilson commented 9 years ago

Could you share a link to that so I can inspect elemetn?

gopperman commented 9 years ago

http://www.nytimes.com/2015/09/16/us/politics/gop-support-for-donald-trump-rising-as-ben-carson-gains-poll-finds.html

noahcooper commented 9 years ago

The problem is that the add-on runs onload, so it's gonna miss anything that gets injected into the DOM later, e.g. NYTimes, CNN, and Google all load the majority of their content with AJAX.

noahcooper commented 9 years ago

I think the only way to handle that ^ is to use a Mutation Observer, like:

new MutationObserver(function() {
  walk(document.body);
}).observe(document.body, {
  childList: true
});

I tried this locally in the console on the Google search results page and it worked!

drewrwilson commented 9 years ago

spot on. Noah, if you commit that change, I'll repackage the plugins and update the chrome and firefox stores

noahcooper commented 9 years ago

I updated the content scripts for Chrome and Firefox, wanna compile 'em and test?

And you'll wanna update the Safari End Script in issue #2 too.

noahcooper commented 9 years ago

The Mutation Observers make a huge difference on sites like Google and CNN.

For some reason I can't quite understand yet, this still doesn't replace instances of some rich asshole in Facebook's search results.

For example, from https://www.facebook.com/search/str/donald%20trump%20some%20rich%20asshole/keywords_top:

<p>
  "You have an ugly soul, Mr. Perkins, and you wrote some very ugly words meant to further 
  separate you from the rest of us plebes. The world can handle 
  <span class="highlightNode">asshole</span> <span class="highlightNode">rich</span> 
  guys. Look at <span class="highlightNode">Donald Trump</span>. That guy is such a 
  fucking train wreck we invite him into pop culture just to laugh at him some more. But 
  even <span class="highlightNode">Donald Trump</span>, the world’s richest birther 
  dumbass, would never think to say he or his golfing buddies were being treated like 
  victims of the Holocaust.
</p>

I wonder why that .highlightNode isn't getting updated ...