Customizing Bugzilla experience with Greasemonkey userscripts - Need help

Thomas Düllmann tdweb at gmx-topmail.de
Sat Aug 14 14:40:27 UTC 2010


Hi there,

it's my first steps with writing Greasemonkey userscripts... I've got 
one up and running, but I am stuck with the one attached to this post.

It all works and comes out nicely, but there's one problem:
It breaks the "Edit" button next to summary (to edit the summary).
I have no idea why. Can you help?

It's a simple thing: I am adding some HTML to include a link button that 
makes copying "Bug 123456 - Sample bug summary" simpler than having to 
carefully select bug no and summary with mouse dragging or 
keyboard-shift-select, while paying attention not to click the bug 
link... With the script, it's just one click on the copy button, press 
Ctrl+C, and you're done (still room for improvement, I know).

Technically, all I do is use onload function to replace the .innerHTML 
of the <span id="summary_alias_container"> with the original .innerHTML 
plus some extra HTML code for my copy button. So I am not actually 
changing anything of the original HTML, just adding. Is it something 
about the DOM which I don't see?

I noticed in FireBug that the currentTarget is different:
(After loading the page, press "Pause at next line" button on the left 
on Firebug's Script tab, then click on (edit)-Summary link; in the 
"Watch" tab on the left, open the tree for Z, scroll down)

currentTarget, after clicking on (edit)-Summary:
Without script: a#editme_action#
With script: Document show_bug.cgi?id=558931#
But why?

Any help would be appreciated, even workarounds as long as they place 
the copy link in the same position.

Thomas


Original HTML:

<span id="summary_alias_container">
  <span id="short_desc_nonedit_display">Autocomplete does not show all 
matching address book entries</span>
  <small class="editme">(<a href="#" id="editme_action">edit</a>)</small>
</span>


New HTML (changed by document.onload event listener):

<span id="summary_alias_container">
  <span id="short_desc_nonedit_display">Autocomplete does not show all 
matching address book entries</span>
  <small class="editme">(<a href="#" id="editme_action">edit</a>)</small>
  <small>(<a href="javascript:void(0)" title="Copy full summary incl. 
bug number" onclick="javascript:prompt('Bug 123456 - Sample summary 
\n\nCtrl+C to copy:','Bug 123456 - Sample summary');">©</a>)</small></span>


Here's the function that changes it:

function onload_handler () {
copytext = "Bug 123456 - Sample summary";
     copyprompt = copytext + "  \\n\\nCtrl+C to copy:";
 
document.getElementById("summary_alias_container").innerHTML+="<small>(<a href='javascript:void(0)' 
title='Copy full summary incl. bug number' 
onclick=\"javascript:prompt('" + copyprompt + "','" + copytext + 
"');\">©</a>)</small>";
}

window.addEventListener('load', onload_handler, false);


-- 
May the road rise to meet you...
-------------- next part --------------
_______________________________________________
dev-apps-bugzilla mailing list
dev-apps-bugzilla at lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-apps-bugzilla


More information about the developers mailing list