aboutsummaryrefslogtreecommitdiffstats
path: root/data/tweaks/viewSource.js
diff options
context:
space:
mode:
Diffstat (limited to 'data/tweaks/viewSource.js')
-rw-r--r--data/tweaks/viewSource.js58
1 files changed, 19 insertions, 39 deletions
diff --git a/data/tweaks/viewSource.js b/data/tweaks/viewSource.js
index fd47cec..d2a9fd1 100644
--- a/data/tweaks/viewSource.js
+++ b/data/tweaks/viewSource.js
@@ -37,55 +37,33 @@
var reAttachmentType = /,\s+([^ )]*)[;)]/;
-function viewAttachmentSource(doc) {
- function addLink(elem, title, href) {
- if (elem.textContent.match(/[\S]/)) {
- elem.appendChild(doc.createTextNode(" | "));
- }
- var link = doc.createElement("a");
- link.href = href;
- link.textContent = title;
- elem.appendChild(link);
- }
- var table = doc.getElementById("attachment_table");
- if (!table)
- return;
- var rows = table.querySelectorAll("tr");
- for ( var i = 0; i < rows.length; ++i) {
- var items = rows[i].querySelectorAll("td");
- if (items.length != 3)
- continue;
- var links = items[0].querySelectorAll("a");
- if (links.length == 0)
- continue;
- var attachHref = links[0].href;
- // get the type of the attachment
- var span = items[0].querySelector(".bz_attach_extra_info");
- if (!span)
- continue;
- var typeName = null;
- try {
- // Match mime type followed by ";" (charset) or ")" (no charset)
- typeName = span.textContent.match(reAttachmentType)[1];
- typeName = typeName.split(";")[0]; // ignore charset following type
- }
- catch (e) {
+function viewAttachmentSource(attachments) {
+ attachments.forEach(function (att) {
+ if (att.length < 1) {
+ return ;
}
+ var typeName = att[2];
+ var elem = att[4];
+ var id = att[1];
+ var attachHref = elem.getAttribute("href");
+
if (typeName == "application/java-archive"
|| typeName == "application/x-jar") {
// Due to the fix for bug 369814, only zip files with this special
// mime type can be used with the jar: protocol.
// http://hg.mozilla.org/mozilla-central/rev/be54f6bb9e1e
- addLink(items[2], "JAR Contents", "jar:" + attachHref
- + "!/");
+ // signature of addLink is addLink(elem, title, href)
+ //
// https://bugzilla.mozilla.org/show_bug.cgi?id=369814#c5 has more
// possible mime types for zips?
+ createDeadLink("viewSourceJAR_" + id, "JAR Contents", elem,
+ "jar:" + attachHref + "!/", [], "pipe", null, null);
}
else if (typeName == "application/zip"
|| typeName == "application/x-zip-compressed"
|| typeName == "application/x-xpinstall") {
- addLink(items[2], "Static ZIP Contents", "jar:"
- + attachHref + "!/");
+ createDeadLink("viewSourceZIP_" + id, "Static ZIP Contents", elem,
+ "jar:" + attachHref + "!/", [], "pipe", null, null);
}
else if (typeName != "text/plain" && typeName != "patch" &&
// Other types that Gecko displays like text/plain
@@ -98,7 +76,9 @@ function viewAttachmentSource(doc) {
// Binary image types for which the "source" is not useful
typeName != "image/gif" && typeName != "image/png"
&& typeName != "image/jpeg") {
- addLink(items[2], "Source", "view-source:" + attachHref);
+ createDeadLink("viewSourcePlain_" + id, "Source", elem,
+ "view-source:" + attachHref, [], "pipe", null, null);
+ }
}
- }
+ )
}