AssignToMe Bookmarklet

I’ve been trying to cut down on the number of addons I run. Previously I blogged about my Bugzilla “assigntome” ubiquity command. Turns out it is really easy to turn it in to a bookmarklet. Just drag AssignToMe to your bookmarks toolbar.

Code:

javascript:(function() {
    var logout_re = /[\s\S]*Log.*out.*[\s]\s*(.*)\s/m;
    var links = document.getElementById('footer').getElementsByClassName('links')[0].getElementsByTagName('li');
    var user_name = links[links.length - 1].textContent.replace(logout_re, '$1');
    var evt = document.createEvent('MouseEvents');
    evt.initMouseEvent('click', true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
    document.getElementById('bz_assignee_edit_action').dispatchEvent(evt);
    document.getElementById('assigned_to').value = user_name;
    document.getElementById('commit_top').click();
})();