keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
Post Reply
Patu
Posts: 31
Joined: September 24th, 2008, 2:20 am

Re: keyconfig 20080929

Post by Patu »

Very nice. Thank you.

By the way: is there any export-import routine to keyconfig?
User avatar
FireLove
Posts: 108
Joined: July 27th, 2008, 5:59 pm

Re: keyconfig 20080929

Post by FireLove »

dorando wrote:Compatibility information has been updated, you likely need to click on Tools > Add-ons > Find Updates (ignore the incorrect message at the top, only the one below the extension name is correct).


Khm, what are you talking about ? :roll:
nigelle
Posts: 117
Joined: June 9th, 2005, 8:30 am
Location: France

Re: keyconfig 20080929

Post by nigelle »

To Dorando :
" nigelle wrote:1) [...]
While that should be possible (but likely better as a separate extension) it does exceed my abilities in multiple ways."
Something similar is done by the "tag" command of iMacros for Firefox (an other product to automate navigation):
https://addons.mozilla.org/en-US/firefox/addon/3863
I have tried this extension but it does not works very well and is too limited as regards program functions. So I have abandoned its use.
I have hoped that the shortcut 1) was a "simple" modification of Ctrl+F present shortcut reusing its coding after having changed text to source ! Ok, I am wrong but as I know nothing on coding an extension or Firefox, it is not abnormal... Your codings seems so simple ! e.g. Ctrl+F is gFindBar.onFindCommand(); and PF3 to go to the next occurrence is gFindBar.onFindAgainCommand(false);

"to restore the window to the non-maximized state. You might be able to use AutoHotkey directly."
I love AutoHotkey for which I have asked the shortcuts but I have tried to use its command to maximize an non-maximized screen but the AHK command does nothing to Firefox screen ! AHK intercept the Windows interface to screen but can do nothing with the Firefox interface to screen which is different. Except find the title line or close a screen... So I use the keyboard : short cuts that call Firefox functions and clipboard to obtain informations from Firefox to bypass this problem.
User avatar
FireLove
Posts: 108
Joined: July 27th, 2008, 5:59 pm

Re: keyconfig 20080929

Post by FireLove »

dorando wrote:If you refer to [Video] DownloadHelper you can use

Code: Select all

document.getElementById("dwhelper-button").open = true;  
to open the dropdown from the toolbar button

Wow, spot on!
dorando wrote:Note that the extension provides dwhelper-quick-key (defaults to Ctrl+Shift+Q, can also be edited from within its options dialog) which seems to download the first file it detects.

It's wasn't working for me on a Mac,
besides I got hooked on keyconfig & you! :lol:
You Rock !!!
=D>
User avatar
FireLove
Posts: 108
Joined: July 27th, 2008, 5:59 pm

Re: keyconfig 20080929

Post by FireLove »

Patu wrote: By the way: is there any export-import routine to keyconfig?


Oh yeah, that would be great to have !!!
Leopoldus
Posts: 353
Joined: April 8th, 2008, 4:29 am

Re: keyconfig 20080929

Post by Leopoldus »

dorando wrote:It seems the Custom Headers module from Mnenhy causes this by somehow making these non-active selection (gray background). I don't know how to retrieve these but if you first left click right of header before selecting it, normal selection should work.


Thank you very much, this trick really works!

However in some cases left click the the right of header can be impossible (eg. if subject line is very long and wrapping is disabled). Do you mean, that due to Mnenhy extension no shortcut will do copying without previous left click? Or this problem affects just Ctrl+C shortcut?
dorando
Posts: 1203
Joined: January 9th, 2004, 9:57 am
Contact:

Re: keyconfig 20080929

Post by dorando »

Patu wrote:By the way: is there any export-import routine to keyconfig?
Nope, changes need to be manually copied from the prefs.js file in your Profile ( those beginning with user_pref("keyconfig ) to another prefs.js.

FireLove wrote:
dorando wrote:Compatibility information has been updated, you likely need to click on Tools > Add-ons > Find Updates (ignore the incorrect message at the top, only the one below the extension name is correct).
Khm, what are you talking about ? :roll:
If you check for updates and only compatibility updates are found the Add-ons Manager will incorrectly claim "No updates were found." (while it actually meant "No new Versions were found") while it does note below the Extension name that "A compatibility update has been applied.".

nigelle wrote:To Dorando :
" nigelle wrote:1) [...]
While that should be possible (but likely better as a separate extension) it does exceed my abilities in multiple ways."
Something similar is done by the "tag" command of iMacros for Firefox (an other product to automate navigation):
https://addons.mozilla.org/en-US/firefox/addon/3863
I have tried this extension but it does not works very well and is too limited as regards program functions. So I have abandoned its use.
I have hoped that the shortcut 1) was a "simple" modification of Ctrl+F present shortcut reusing its coding after having changed text to source ! Ok, I am wrong but as I know nothing on coding an extension or Firefox, it is not abnormal... Your codings seems so simple ! e.g. Ctrl+F is gFindBar.onFindCommand(); and PF3 to go to the next occurrence is gFindBar.onFindAgainCommand(false);
The find shortcuts itself call functions from the quite complex <findbar> (49k) which itself only does part of the work. Incremental searching the source and highlighting it is surely beyond my current skills.

Something similar to what iMacros does (which seems to translate the input to XPath) could be:

Code: Select all

var clipboard = readFromClipboard().match(/(nigelle);([0-9]+);(.*)/);
if(!
clipboard) return;

var node = content.document.evaluate(clipboard[3], content.document, null, 7, null).snapshotItem(clipboard[2]-1);
node.focus();

var e = content.document.createEvent("MouseEvents");
e.initMouseEvent("click", true, true, null, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
node.dispatchEvent(e);  
You can test some on the iMacros demo page by copying one of the following to your clipboard:
nigelle;2;//a[contains(text(),"Click to open this page")]
nigelle;1;//a[@href="page1.htm"]
nigelle;1;//input[@value="your E-mail here"]

The format is identifier;occurrence;XPath while for XPath //tag[@attribute="value"] or //tag[contains(text(),"text content")] should cover many cases.

Leopoldus wrote:Do you mean, that due to Mnenhy extension no shortcut will do copying without previous left click?
Likely, but others might find a way.

As a workaround you might want to add

Code: Select all

mail-headerfield.MnenhyTextField
{
  -moz-binding: url(chrome://messenger/content/mailWidgets.xml#mail-headerfield) !important;
}

#expandedsubjectBox.MnenhyTextField
{
 font-weight: bold;
}
to your userChrome.css. Note that you would loose the "Copy Selection" and "Copy Header Value" menuitems and Encoders/Decoders submenu (still available by right clicking on the message body).
Leopoldus
Posts: 353
Joined: April 8th, 2008, 4:29 am

Re: keyconfig 20080929

Post by Leopoldus »

As a workaround you might want to add

Thanks! I'll try this.
nigelle
Posts: 117
Joined: June 9th, 2005, 8:30 am
Location: France

Re: keyconfig 20080929

Post by nigelle »

To Dorando
Re: Your XPath shortcut "(which seems to translate the input to XPath)"
I have tested your examples, they work fine : thanks !
I have tested a fourth one that should fail :
nigelle;2;//a[contains(text(),"Zzzz")]
but nothing occurs ! Can you add, at the end of the function, the code to replace the clipboard content by the now usual Found (success) or NotFound (failure) strings ?
This will allow to detect an error (e.g. due to changes in the application screen) : presently the script will be waiting indefinitely.

I need some clarifications, I assume that :
-the first field "identifier" is just a place holder and that I can replace "nigelle" by any other string (but the same in shortcut and clipboard).
-the 2nd field "occurrence" is numeric [0-9] but can be greater than 9 e.g. 12.
-the 3rd field "XPath" : "tag" is the htlm tag without < and can be a td input (any others ?); should it be the last tag before what I search for ?
[@attribute="value"] : Where can I find a list of attribute ? I know href src(?) [@name="subscribe_email"] is probably valid instead of [@value="your E-mail here"]
How to select something looking like 'onclick="functionXx(...)' ? May be onclick is an attribute...
[contains(text(),"text content")] : does this needs that the "text content" appear on the screen as text or can I select any string with any attribute in the source ?
"while for XPath //tag[@attribute="value"] or //tag[contains(text(),"text content")] should cover many cases." Are there other formats ? Where can I find a list and description of them ?
Are joker characters as * supported as in Imacros ?

I'll leave my normal Internet connection for 2 weeks. I'll see you later in 3 to 4 weeks after more experiences...
Miccovin
Posts: 51
Joined: February 9th, 2007, 12:44 am

Re: keyconfig 20080929

Post by Miccovin »

Hi,

i'm searching a script to "focus the last visited tab".

Any ideas?

Thanks,
Mic
dorando
Posts: 1203
Joined: January 9th, 2004, 9:57 am
Contact:

Re: keyconfig 20080929

Post by dorando »

nigelle wrote:Can you add, at the end of the function, the code to replace the clipboard content by the now usual Found (success) or NotFound (failure) strings ?
Try

Code: Select all

var ClipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.
getService(Components.interfaces.nsIClipboardHelper);

var clipboard = readFromClipboard().match(/(nigelle);([0-9]+);(.*)/);
if(!
clipboard) return;

try {
var node = content.document.evaluate(clipboard[3], content.document, null, 7, null).snapshotItem(clipboard[2]-1);
}
 catch(err) { ClipboardHelper.copyString(err); return; }

if(!
node) {
 ClipboardHelper.copyString("NotFound"); return;
}

ClipboardHelper.copyString("Found");
node.focus();

var e = content.document.createEvent("MouseEvents");
e.initMouseEvent("click", true, true, null, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
node.dispatchEvent(e); 


nigelle wrote:-the first field "identifier" is just a place holder and that I can replace "nigelle" by any other string (but the same in shortcut and clipboard).
Yes.

nigelle wrote:-the 2nd field "occurrence" is numeric [0-9] but can be greater than 9 e.g. 12.
Yes.

nigelle wrote:-the 3rd field "XPath" : "tag" is the htlm tag without < and can be a td input (any others ?);
Yes.

nigelle wrote:should it be the last tag before what I search for ?
Yes if you meant <tag>what you search for</tag>.

nigelle wrote:Where can I find a list of attribute ?
The Mozilla Developer Center has a HTML element reference which does list some attributes as do other site (like the Web Design Group), the W3C Recommendation has an Index of Attributes. I would recommend using DOM Inspector or looking into the source as only attributes that are actually set should be queryable.

nigelle wrote:[@name="subscribe_email"] is probably valid instead of [@value="your E-mail here"]
Yes, that can be used instead. You can also use multiple checks like (all need to match):
//input[@value="your E-mail here"][@name="subscribe_email"]

nigelle wrote:How to select something looking like 'onclick="functionXx(...)' ? May be onclick is an attribute...
Yes, onclick is also an attribute. You can use
//a[@onclick]
to select an <a> element with an onclick attribute without checking for a value.

nigelle wrote: [contains(text(),"text content")] : does this needs that the "text content" appear on the screen as text or can I select any string with any attribute in the source ?
It should be <tag>text content</tag>. For attribute you could use [contains(@attribute,"text content")]

nigelle wrote:Are there other formats ? Where can I find a list and description of them ?
The Mozilla Developer Center has a XPath section.

nigelle wrote:Are joker characters as * supported as in Imacros ?
Nope, I'm not sure what iMacros does for that. Multiple contains() checks might suffice instead.

Miccovin wrote:i'm searching a script to "focus the last visited tab".
If you meant the previous selected tab, Firefox doesn't keep a reference of it IIRC. Some extensions like FLST or Tab Mix Plus might keep references, but they likely store that differently.
jimbothigpen
Posts: 3
Joined: February 12th, 2009, 11:45 am

Strings instead of "Hotkeys"?

Post by jimbothigpen »

First off, this extension has made my Firefox navigation soooo much simpler! Many thanks! Now for my question:

Is it possible to use a string for the keybinding rather than "hotkeys"? For instance, I'd like to map ":q<enter>" to the exit command. I know the vimperator extension will let me use my beloved vim style keybindings, but I'd prefer to not have the rest of the goodies that the vimperator extension installs (like disabling the rest of my custom key bindings and the text-input area beneath the statusbar).

Thanks!
Jimbo
dorando
Posts: 1203
Joined: January 9th, 2004, 9:57 am
Contact:

Re: Strings instead of "Hotkeys"?

Post by dorando »

jimbothigpen wrote:Is it possible to use a string for the keybinding rather than "hotkeys"? For instance, I'd like to map ":q<enter>" to the exit command.
Not directly, but you could assign the ":" to a new key containing

Code: Select all

if(keyconfig.vim) return;
keyconfig.vim true;

var 
vim document.getElementById("navigator-throbber") || {label:""}
vim.label " vim: ";

function 
listen(event) {
 if(
event.keyCode == event.DOM_VK_RETURN) {

  switch(
vim.label.substr(6)) {
   case 
"q"goQuitApplication(); stop(); return;
  }

 } else if(
event.keyCode == event.DOM_VK_ESCAPE) {
  
stop(); return;
 }

 if(!
event.charCode) return;

 
vim.label += String.fromCharCode(event.charCode);
}

function 
stop() {
 
window.removeEventListener("keypress",listen,true);
 
vim.label "";
 
delete keyconfig.vim;
}

window.addEventListener("keypress",listen,true);  
Press Escape to exit the mode, current text will be displayed on the Activity Indicator (top right) if it is on the toolbar. Note that using ":" as the start key will fail while you're within a text box.
jimbothigpen
Posts: 3
Joined: February 12th, 2009, 11:45 am

Re: keyconfig 20080929

Post by jimbothigpen »

That is great! I'm working out a generic list of commands to implement for "vim-mode" now, which I'll post here when it's complete so others can use it as well. I do have a couple other questions that others here may be able to answer.

First, is there any way to make Firefox ignore any other key bindings while in the new "vim-mode"? For instance, if I have key "f" mapped with keyconfig to open my feed sidebar, and key "p" mapped with keyconfig to open my Flock people sidebar, but I add

case "pf": BrowserForward(); stop(); return;

to my list of "vim-mode" commands, then my people and feed sidebars open in addition to my page forward command.

Second (and I'm sure I'm just showing my scripting ignorance here), how can I use a case like

case "g <url_input>": loadURI("<url_input>"); stop(); return;

or

case "t <number>": BrowserNumberTabSelection(event, <number>); stop(); return;

where url_input is whatever user input comes after "g<space>" or number is whatever input happens to come after "t<space>"?

Thanks again,
Jimbo
dorando
Posts: 1203
Joined: January 9th, 2004, 9:57 am
Contact:

Re: keyconfig 20080929

Post by dorando »

Try

Code: Select all

if(keyconfig.vim) return;
keyconfig.vim = true;

var vim = document.getElementById("navigator-throbber") || {label:""}
vim.label = " vim: ";

function listen(event) {
 event.stopPropagation(); event.preventDefault();

 if(event.keyCode == event.DOM_VK_RETURN) {

  switch(vim.label.substr(6)) {
   case "pf": BrowserForward(); stop(); return;
   case "q": goQuitApplication(); stop(); return;
  }
  if(vim.label.match(/(.+)/))  { loadURI(RegExp.$1); stop(); return; }
  if(vim.label.match(/(.+)/))  { BrowserNumberTabSelection(event, RegExp.$1); stop(); return; }

 } else if(event.keyCode == event.DOM_VK_ESCAPE) {
  stop(); return;
 } else if(event.keyCode == event.DOM_VK_BACK_SPACE) {
  if(vim.label.length > 6)
   vim.label = vim.label.substr(0,vim.label.length-1);
  else
   stop
();
  return;
 }

 if(!event.charCode) return;

 vim.label += String.fromCharCode(event.charCode);
}

function stop() {
 delete keyconfig.vim;
 window.removeEventListener("keypress",listen,true);
 vim.label = "";
}

window.addEventListener("keypress",listen,true); 
Post Reply