I'm trying to create a browser extension that automatically replaces the twitter avatars in the stream from their _normal version eg _normal to their _bigger version (replace the _normal.jpg string with _bigger.jpg)
The following code has no problem doing this replacement when performed externally in a jsfiddle jsfiddle to test.
$("img.avatar").replaceWith(function () {
if ($(this).attr("src")) {
return $(this).attr("src", $(this).attr("src").replace("_normal", "_bigger"));
} else {
return $(this);
}
});
But when I try to use the same code in the console on the twitter page all the avatar images just disappear. Why is this?