Bookmarklet to trigger attach of mp4 to tweet


#1

Hi all,
I created an addon which creates a small mp4. And when a user has the twitter tweet dialog open, or facebok message thing focused. If they click my browser toolbar button it will attach the image.

When I open the tweet dialog, I can attach images by doing this:

var img = document.createElement('img');
img.setAttribute('src', 'data:image/png;base64,iVBOR...........YII=');
var richbox = document.getElementById('tweet-box-global');
richbox.appendChild(img);

And then this gets attached.

However I am trying to do this with the data uri of a mp4.

Doing this does not work:

var video = document.createElement('video');
video.setAttribute('src', 'data:video/mp4,.........');
rich.appendChild(video);

Does anyone know how to get this to work for video please? Is there a function I can call from a bookmarklet to attach my mp4 video?

Here is a screencast showing me attaching a png to the tweet with the code above: