diff --git a/dreditor.user.js b/dreditor.user.js
index 6981dca..7135426 100644
--- a/dreditor.user.js
+++ b/dreditor.user.js
@@ -1577,11 +1577,11 @@ Drupal.behaviors.dreditorIssueSummaryTemplate = function (context) {
// Retrieve the template.
$templateText = $(data).find('#node-1326662 code').text();
- // If we are on a node edit page, add an additional header for the
- // original report.
var isNodeEdit = (location.pathname.search('node/add') == -1);
- if (isNodeEdit) {
- $templateText += '
Original report by [username]
';
+ // If we are on a node add page, remove the "Original report by"
+ // section.
+ if (!isNodeEdit) {
+ $templateText = $templateText.replace('Original report by [username]
', '');
}
// Add some whitespace.
@@ -1608,10 +1608,13 @@ Drupal.behaviors.dreditorIssueSummaryTemplate = function (context) {
$.get(nodePath[0], function (data) {
// Find the link to the original poster's profile.
var $profileLink = $(data).find('div.node > div.submitted a');
+ var profileText = $profileLink.text();
- // Assemble and insert markup for a profile link.
- profileLinkMarkup = 'by ' + $profileLink.text() + '';
- $('#edit-body').val($('#edit-body').val().replace(/by \[username\]/, profileLinkMarkup));
+ if (profileText.length) {
+ // Assemble and insert markup for a profile link.
+ profileLinkMarkup = 'by ' + profileText + '';
+ $('#edit-body').val($('#edit-body').val().replace('by [username]', profileLinkMarkup));
+ }
});
}
}
@@ -1623,7 +1626,7 @@ Drupal.behaviors.dreditorIssueSummaryTemplate = function (context) {
);
// Add a link to view the issue summary instructions.
- $('Issue summary standards')
+ $('Issue summary standards')
.appendTo($label)
.before('(')
.after(')');