Skip to content

Instantly share code, notes, and snippets.

@zipcode
Created October 2, 2014 23:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zipcode/29ba7327ce9f2a148617 to your computer and use it in GitHub Desktop.
Save zipcode/29ba7327ce9f2a148617 to your computer and use it in GitHub Desktop.
javascript:(function(){var g="#gamergate";var f=function(t){return t.split(' ').map(function(w){return w.toLowerCase()==g?w:'butt'}).join(' ')};var es=document.getElementsByClassName("tweet-text");for(var i=0;i<es.length;i++){if(es[i].innerText.toLowerCase().indexOf(g)>0)es[i].innerText=f(es[i].innerText)}})()
@webbedspace
Copy link

Let me code-golf this a bit:

javascript:void [].slice.call(document.querySelectorAll(".twitter-hashtag")).forEach(function(e){e.innerText=e.innerText.replace(/#gamergate/ig,"#buttgate");});

This targets the hashtag <a> tag rather than the full tweet's text, so it doesn't clobber any other hyperlinks in the tweet and affects multiple instances of the hashtag in the same tweet.

@zipcode
Copy link
Author

zipcode commented Oct 3, 2014

Mine replaces every word that isn't #gamergate with "butt" :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment