12/09/13 07:30:19.18 bM0esfAg0
nsContextMenu.prototype.viewPartialSource_orig = nsContextMenu.prototype.viewPartialSource;
nsContextMenu.prototype.viewPartialSource = function(context) {
if (context == "mathml") {
this.viewPartialSource_orig("mathml");
return;
}
var focusedWindow = document.commandDispatcher.focusedWindow;
if (!focusedWindow || focusedWindow == window)
focusedWindow = content;
if (!focusedWindow.getSelection()) return;
var x = focusedWindow.document.createElement("div");
x.appendChild(focusedWindow.getSelection().getRangeAt(0).cloneContents());
var sel = x.innerHTML;
if(!sel) {
alert("You didn't select any text.");
return;
}
var doctype = focusedWindow.document.contentType;
var charset = "utf-8";
var url = "view-source:data:" + doctype + ";charset=" + charset +
"," + encodeURIComponent(sel);
var tab = gBrowser.addTab(url);
window.setTimeout(function() {
tab.linkedBrowser.contentDocument.title = "DOM Source of Selection";
});
}