You could create your own function with a different kMaxSelectionLen.
Code: Select all
function getBrowserSelection(aCharLen) {
const kMaxSelectionLen = 999;
const charLen = Math.min(aCharLen || kMaxSelectionLen, kMaxSelectionLen);
let [element, focusedWindow] = BrowserUtils.getFocusSync(document);
var selection = focusedWindow.getSelection().toString();
if (!selection) {
var isOnTextInput = function isOnTextInput(elem) {
return elem instanceof HTMLTextAreaElement ||
(elem instanceof HTMLInputElement && elem.mozIsTextField(true));
};
if (isOnTextInput(element)) {
selection = element.QueryInterface(Ci.nsIDOMNSEditableElement)
.editor.selection.toString();
}
}
if (selection) {
if (selection.length > charLen) {
var pattern = new RegExp("^(?:\\s*.){0," + charLen + "}");
pattern.test(selection);
selection = RegExp.lastMatch;
}
selection = selection.trim().replace(/\s+/g, " ");
if (selection.length > charLen)
selection = selection.substr(0, charLen);
}
return selection;
}
var selection = getBrowserSelection();
if (!selection) return;
var str = readFromClipboard();
if (str) selection = str + " " + selection;
var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].
getService(Ci.nsIClipboardHelper);
clipboard.copyString(selection);
http://mxr.mozilla.org/mozilla-release/ ... rSelection