Created
April 15, 2015 13:29
-
-
Save wolph/78c85b62246a91af18a3 to your computer and use it in GitHub Desktop.
Assign bug to me in Bugzilla
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Assign to me (Bugzilla) | |
// @namespace http://wol.ph/ | |
// @version 1.0 | |
// @description | |
// @match http://bugzilla.3xo.eu/show_bug.cgi?id=* | |
// @copyright 2015, Wolph | |
// ==/UserScript== | |
var assigned_to_field = document.getElementsByName('assigned_to')[0]; | |
var form = document.getElementsByName('changeform')[0]; | |
form.target = '_blank'; | |
function assignTo(email){ | |
assigned_to_field.value = email; | |
document.getElementById('knob-reassign').checked = true; | |
document.getElementById('comment').value = 'Assigning to ' + email; | |
form.submit(); | |
} | |
function acceptBug(){ | |
document.getElementById('knob-accept').checked = true; | |
form.submit(); | |
} | |
function assignToMe(){ | |
var links = document.getElementsByTagName('a'); | |
var i = links.length; | |
while(i--){ | |
var link = links[i]; | |
if(link.innerText == 'My Requests'){ | |
var email = decodeURIComponent(link.href.match(/requester=([^&]+)/)[1]); | |
assignTo(email); | |
acceptBug(); | |
} | |
} | |
} | |
function createButton(){ | |
var button = document.createElement('span'); | |
button.id = 'assign_to_me'; | |
button.innerHTML = 'me'; | |
button.style.border = '1px solid #666'; | |
button.style.padding = '2px'; | |
button.style.margin = '2px'; | |
button.style.cursor = 'hand'; | |
button.onclick = assignToMe; | |
assigned_to_field.parentNode.insertBefore( | |
button, assigned_to_field); | |
} | |
createButton(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment