MozillaZine


keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
morat
 
Posts: 4343
Joined: February 3rd, 2009, 6:29 pm

Post Posted September 27th, 2014, 1:20 am

@t3l0zvxqIiXuzuH0

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

firefoxuse
 
Posts: 1086
Joined: November 8th, 2011, 12:06 pm

Post Posted September 28th, 2014, 12:19 pm

hello!

I want now to set single right click on webpage to close a tab and double right click on webpage to reopen the last closed tab!

and in case I want to trigger the context menu, I would like to use CTRL+right click!

any idea?

thanks!

sridhar
 
Posts: 184
Joined: June 18th, 2004, 2:54 pm

Post Posted September 29th, 2014, 7:13 am

Hello,

I would like the key press 'd' to invoke the "+ Add to Delicious" bookmarklet whose code is below:

Code: Select all
javascript:(function(e,t){var%20n=e.document;setTimeout(function(){function%20a(e){if(e.data==="destroy_bookmarklet"){var%20r=n.getElementById(t);if(r){n.body.removeChild(r);r=null}}}var%20t="DELI_bookmarklet_iframe",r=n.getElementById(t);if(r){return}var%20i="https://delicious.com/save?source=bookmarklet&",s=n.createElement("iframe");s.id=t;s.src=i+"url="+encodeURIComponent(e.location.href)+"&title="+encodeURIComponent(n.title)+"&note="+encodeURIComponent(""+(e.getSelection?e.getSelection():n.getSelection?n.getSelection():n.selection.createRange().text))+"&v=1.1";s.style.position="fixed";s.style.top="0";s.style.left="0";s.style.height="100%25";s.style.width="100%25";s.style.zIndex="16777270";s.style.border="none";s.style.visibility="hidden";s.onload=function(){this.style.visibility="visible"};n.body.appendChild(s);var%20o=e.addEventListener?"addEventListener":"attachEvent";var%20u=o=="attachEvent"?"onmessage":"message";e[o](u,a,false)},1)})(window)


Can someone kindly tell me how I can add a key for this in keyconfig?

sridhar
 
Posts: 184
Joined: June 18th, 2004, 2:54 pm

Post Posted September 29th, 2014, 7:23 am

Got it.

Code: Select all
loadURI('javascript:(function(e,t){var%20n=e.document;setTimeout(function(){function%20a(e){if(e.data==="destroy_bookmarklet"){var%20r=n.getElementById(t);if(r){n.body.removeChild(r);r=null}}}var%20t="DELI_bookmarklet_iframe",r=n.getElementById(t);if(r){return}var%20i="https://delicious.com/save?source=bookmarklet&",s=n.createElement("iframe");s.id=t;s.src=i+"url="+encodeURIComponent(e.location.href)+"&title="+encodeURIComponent(n.title)+"&note="+encodeURIComponent(""+(e.getSelection?e.getSelection():n.getSelection?n.getSelection():n.selection.createRange().text))+"&v=1.1";s.style.position="fixed";s.style.top="0";s.style.left="0";s.style.height="100%25";s.style.width="100%25";s.style.zIndex="16777270";s.style.border="none";s.style.visibility="hidden";s.onload=function(){this.style.visibility="visible"};n.body.appendChild(s);var%20o=e.addEventListener?"addEventListener":"attachEvent";var%20u=o=="attachEvent"?"onmessage":"message";e[o](u,a,false)},1)})(window)')

alex3518
 
Posts: 8
Joined: January 2nd, 2014, 3:51 pm

Post Posted September 29th, 2014, 10:53 am

Nice Work !!!

t3l0zvxqIiXuzuH0
 
Posts: 92
Joined: August 17th, 2014, 5:57 am

Post Posted October 1st, 2014, 4:09 am

morat wrote:@t3l0zvxqIiXuzuH0

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

Hi, morat. Didn't see your reply till now. In the meantime I tried this:
Code: Select all
if (!getBrowserSelection())
 { return; }
var oldClip = readFromClipboard();
goDoCommand("cmd_copy");
if (oldClip)
 { var newClip = readFromClipboard();
   str = oldClip + " " + newClip;
   var clipboard = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper);
   clipboard.copyString(str); }

It seems to work fine but I'll try your solution anyway. Thanks.

firefoxuse
 
Posts: 1086
Joined: November 8th, 2011, 12:06 pm

Post Posted October 1st, 2014, 11:33 am

hello!

can you tell me please how to make "right ctrl key" (only right) to close the current tab?

thanks!

rubo77
 
Posts: 6
Joined: March 22nd, 2009, 4:25 am

Post Posted October 8th, 2014, 2:39 pm

Sorry to reopen such an old post, but many sites link on this page, and the KeyConfig addon is not available for new Thunderbirds in the mozilla addons page.

Is there a new version of KeyConfig, that works on Thunderbird 31?

___ EDIT:
I found out, that the link in the very first post here still works. It is old, but it works in Thunderbird 33!
Last edited by rubo77 on October 22nd, 2014, 12:21 pm, edited 1 time in total.

firefoxuse
 
Posts: 1086
Joined: November 8th, 2011, 12:06 pm

Post Posted October 22nd, 2014, 9:59 am

anyone for my request please????????

abcuser
 
Posts: 261
Joined: March 12th, 2007, 11:19 pm

Post Posted November 4th, 2014, 7:07 am

Hi,
In our company we are using Firefox portable 31 ESR standard browser at all of the end-users and this is the only browser possible to work with our internal web applications (all other browses are blocked at web server).

When user copies some text from world processor like Microsoft Word to our in house made web application there can be some exotic characters pasted into the web application input fields. This characters are stored in relation database and when XML files are generated we get broken XML files. Which characters are exotic - see web page: http://www.robelle.com/smugbook/ascii.html first table Control Characters are the characters with hexadecimal code between 1 and 31.

I thought we could solve this problem in Firefox with:
1. When CTRL+V is executed in browser, then:
2. See the content of clipboard, remove all exotic characters like hexadecimal between 1 and 31 from it and
3. Paste text (to e.g Firefox input field).
Is there a way of doing this in Keyconfig?

Thanks

firefoxuse
 
Posts: 1086
Joined: November 8th, 2011, 12:06 pm

Post Posted November 4th, 2014, 12:29 pm

tell your company they must pay for it

abcuser wrote:Hi,
In our company we are using Firefox portable 31 ESR standard browser at all of the end-users and this is the only browser possible to work with our internal web applications (all other browses are blocked at web server).

When user copies some text from world processor like Microsoft Word to our in house made web application there can be some exotic characters pasted into the web application input fields. This characters are stored in relation database and when XML files are generated we get broken XML files. Which characters are exotic - see web page: http://www.robelle.com/smugbook/ascii.html first table Control Characters are the characters with hexadecimal code between 1 and 31.

I thought we could solve this problem in Firefox with:
1. When CTRL+V is executed in browser, then:
2. See the content of clipboard, remove all exotic characters like hexadecimal between 1 and 31 from it and
3. Paste text (to e.g Firefox input field).
Is there a way of doing this in Keyconfig?

Thanks

Springtime
 
Posts: 68
Joined: November 8th, 2013, 8:59 pm

Post Posted November 5th, 2014, 4:07 am

Is this bug reproducible to anyone else? I've set 'Toggle Bookmarks Toolbar' to a hotkey and noticed that if I toggle it via the hotkey the bookmarks don't appear, but if I instead right-click Firefox and select it via the context menu the bookmarks do appear.

FWIW I also keep my addon icons there as an alternate way of quickly toggling them. I've had this issue for months but just put up with it, hoping someone here can shed some light on it.

meeotch
 
Posts: 53
Joined: November 11th, 2002, 9:16 pm

Post Posted November 7th, 2014, 7:29 pm

Just updated TB from 24 to 31 (and hence KeyConfig), and it seems to have broken my hotkey for moving a message to a particular folder. Is there any reason why the following code would no longer be valid?

MsgMoveMessage(GetMsgFolderFromUri("mailbox://nobody@Local%20Folders/5%20-%20BLACK%20HOLE"));

Farg! Tried reverting to 24.1, and it was still broken. In fact, using the Move command from the menus didn't work either. Restarting seems to fix it temporarily, but then it eventually stops responding again.

morat
 
Posts: 4343
Joined: February 3rd, 2009, 6:29 pm

Post Posted November 9th, 2014, 5:37 am

@meeotch

Try this:

Code: Select all
var targetUri = "mailbox://nobody@Local%20Folders/Trash";
var targetFolder = MailUtils.getFolderForURI(targetUri);
MsgMoveMessage(targetFolder);

Here is how to show the selected folder URI.

Code: Select all
alert(GetFirstSelectedMsgFolder().URI);

t3l0zvxqIiXuzuH0
 
Posts: 92
Joined: August 17th, 2014, 5:57 am

Post Posted November 12th, 2014, 5:47 am

Hi, is there a command to close current window, but only if there's more than one window open (i.e. NOT exit FF if the window is the last one)?
Thanks.

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 2 guests