Created
December 19, 2012 19:46
-
-
Save AlexLakatos/4339864 to your computer and use it in GitHub Desktop.
Bookmarklet for finding all bug reporters in a component 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
javascript:{email%20=%20document.querySelectorAll(".bz_reporter_column%20span");%20reporter%20=%20document.querySelectorAll(".bz_reporter_realname_column%20span");%20emails%20=%20[];%20function%20inFinals(x)%20{%20%20%20var%20uniq%20=%20false;%20%20%20var%20id;%20%20%20for(j%20=%200;%20j%20<%20emails.length;%20j++)%20{%20%20%20%20%20if%20(emails[j].email%20===%20x)%20{%20%20%20%20%20%20%20uniq%20=%20true;%20%20%20%20%20%20%20id%20=%20j;%20%20%20%20%20}%20%20%20}%20%20%20if%20(uniq)%20emails[id].count%20=%20emails[id].count%20+%201;%20%20%20return%20uniq;%20}%20for(i=0;%20i<email.length;%20i++)%20{%20%20%20if%20(!inFinals(email[i].title))%20{%20%20%20%20%20emails.push({reporter:%20reporter[i].title%20,%20email:%20email[i].title,%20count:%201});%20%20%20%20%20%20%20%20}%20%20%20%20}%20header%20=%20document.getElementById("header");%20table%20=%20document.createElement('table');%20var%20tr=document.createElement('thead');%20var%20td1%20=%20document.createElement('td');%20td1.textContent%20=%20"Name";%20var%20td2%20=%20document.createElement('td');%20td2.textContent%20=%20"Email";%20var%20td3%20=%20document.createElement('td');%20td3.textContent%20=%20"Bugs%20logged%20for%20component";%20tr.appendChild(td1);%20tr.appendChild(td2);%20tr.appendChild(td3);%20table.appendChild(tr);%20%20for(i=0;%20i<emails.length;%20i++)%20{%20%20%20var%20tr=document.createElement('tr');%20%20%20%20%20%20var%20td1%20=%20document.createElement('td');%20%20%20td1.textContent%20=%20emails[i].reporter;%20%20%20%20%20%20var%20td2%20=%20document.createElement('td');%20%20%20td2.textContent%20=%20emails[i].email;%20%20%20%20%20%20var%20td3%20=%20document.createElement('td');%20%20%20td3.textContent%20=%20emails[i].count;%20%20%20%20%20%20tr.appendChild(td1);%20%20%20tr.appendChild(td2);%20%20%20tr.appendChild(td3);%20%20%20table.appendChild(tr);%20}%20header.appendChild(table);};void(0); |
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
/* | |
* This is a JavaScript Scratchpad. | |
* | |
* Enter some JavaScript, then Right Click or choose from the Execute Menu: | |
* 1. Run to evaluate the selected text (Ctrl+R), | |
* 2. Inspect to bring up an Object Inspector on the result (Ctrl+I), or, | |
* 3. Display to insert the result in a comment after the selection. (Ctrl+L) | |
*/ | |
email = document.querySelectorAll(".bz_reporter_column span"); | |
reporter = document.querySelectorAll(".bz_reporter_realname_column span"); | |
emails = []; | |
function inFinals(x) { | |
var uniq = false; | |
var id; | |
for(j = 0; j < emails.length; j++) { | |
if (emails[j].email === x) { | |
uniq = true; | |
id = j; | |
} | |
} | |
if (uniq) emails[id].count = emails[id].count + 1; | |
return uniq; | |
} | |
for(i=0; i<email.length; i++) { | |
if (!inFinals(email[i].title)) { | |
emails.push({reporter: reporter[i].title , email: email[i].title, count: 1}); | |
} | |
} | |
header = document.getElementById("header"); | |
table = document.createElement('table'); | |
var tr=document.createElement('thead'); | |
var td1 = document.createElement('td'); | |
td1.textContent = "Name"; | |
var td2 = document.createElement('td'); | |
td2.textContent = "Email"; | |
var td3 = document.createElement('td'); | |
td3.textContent = "Bugs logged for component"; | |
tr.appendChild(td1); | |
tr.appendChild(td2); | |
tr.appendChild(td3); | |
table.appendChild(tr); | |
for(i=0; i<emails.length; i++) { | |
var tr=document.createElement('tr'); | |
var td1 = document.createElement('td'); | |
td1.textContent = emails[i].reporter; | |
var td2 = document.createElement('td'); | |
td2.textContent = emails[i].email; | |
var td3 = document.createElement('td'); | |
td3.textContent = emails[i].count; | |
tr.appendChild(td1); | |
tr.appendChild(td2); | |
tr.appendChild(td3); | |
table.appendChild(tr); | |
} | |
header.appendChild(table); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment