keyconfig 20110522
-
- Posts: 17
- Joined: October 5th, 2008, 9:26 pm
Re: keyconfig 20080929
Is there a way to have it where in a keybinding after it pastes the text it submits the text (presses enter for me). Lets just say as an example its google, so it pastes something into the google textbox and submits the search for me.
I was reading on earlier pages that you can create commands with a mouse click. I tried (but failed) in making a double click copy command. So I can double click a word and it copies it? How would that be done?
Thanks.
And as a sidenote, I think dorando might just be the coolest person on earth, honestly, I wish there was more people like him!
I was reading on earlier pages that you can create commands with a mouse click. I tried (but failed) in making a double click copy command. So I can double click a word and it copies it? How would that be done?
Thanks.
And as a sidenote, I think dorando might just be the coolest person on earth, honestly, I wish there was more people like him!
Last edited by zillamanilla on October 6th, 2008, 7:17 pm, edited 7 times in total.
-
- Posts: 87
- Joined: June 26th, 2007, 6:17 pm
Re: keyconfig 20080929
I am using Foxlingo toolbar for translation.
Can you tell me what is the code to toggle on/off foxlingo toolbar?
Can you tell me what is the code to toggle on/off foxlingo toolbar?
-
- Posts: 87
- Joined: June 26th, 2007, 6:17 pm
Re: keyconfig 20080929
I use a custom button " auto context menu on selection". which will pop up context menu immdiately when you highlight some text on webpages.Very handy, but sometimes i want to toggle off this button for momentary halt for this function.
and the code of this custom button as below:
then can you please tell me what is the code of toggle on/off "auto context menu on selection" function?
Thanks in advance.
and the code of this custom button as below:
Code: Select all
var prefs=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
try{
var cb_autoContextmenu = prefs.getBoolPref("cb_autoContextmenu" );
}catch(e){
prefs.setBoolPref("cb_autoContextmenu",true );
}
prefs.setBoolPref("cb_autoContextmenu", !prefs.getBoolPref("cb_autoContextmenu" ));
this.checked = prefs.getBoolPref("cb_autoContextmenu" );
then can you please tell me what is the code of toggle on/off "auto context menu on selection" function?
Thanks in advance.
-
- Posts: 1203
- Joined: January 9th, 2004, 9:57 am
- Contact:
Re: keyconfig 20080929
Seems to work for menettrotter wrote:dorando wrote:. Replace "PersonalToolbar" with "nav-bar" for the Navigation Toolbar, or "toolbar-menubar" for the Menu.Code: Select all
var toolbar = document.getElementById("PersonalToolbar");
toolbar.collapsed = !toolbar.collapsed;
document.persist(toolbar.id, "collapsed");
This set of code still works on PersonalToolbar( aka, bookmark toolbar).
But it doesn't work on Menu bar after replacing Id.
Don't know what about navigation bar ,because i don't wanna try .
Code: Select all
var toolbar = document.getElementById("toolbar-menubar");
toolbar.collapsed = !toolbar.collapsed;
document.persist(toolbar.id, "collapsed");
Since I don't know how to get the link directly, looping through all available until one matches the url is the best I can come up withnettrotter wrote:Then what is the code to copy link text when mouse hovers over a link?
and what is the code to copy link text and location together when mouse hovers over a link with the form of "link text" - "link location"?
Code: Select all
if(XULBrowserWindow.overLink)
for (var i = 0, links = content.document.links, l = links.length ; i < l; i++)
if(links[i].href == XULBrowserWindow.overLink) {
Components.classes["@mozilla.org/widget/clipboardhelper;1"]
.getService(Components.interfaces.nsIClipboardHelper)
.copyString(links[i].text + " - " + links[i].href);
break;
}
Code: Select all
.copyString(links[i].text);
Using single letters as shortcut won't work in text boxes/form elements or if Search for text when I start typing is enabled as these are handled before it reaches the <key> added by keyconfig.zillamanilla wrote:But I'm having a problem with setting a keybinding to Paste. I'm trying to useas the command and using one letter as the keybinding "V" (instead of control+v). But it doesn't want to work.Code: Select all
goDoCommand('cmd_paste');
Tryzillamanilla wrote:And while I'm at it, is there a way to switch to another Firefox window? Like if I have two open and I want to go to the other one.
Code: Select all
var enumerator =
Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator)
.getZOrderDOMWindowEnumerator("navigator:browser",true);
if(enumerator.hasMoreElements()) enumerator.getNext();
if(enumerator.hasMoreElements()) enumerator.getNext().focus();
Either simulating a keypress:zillamanilla wrote:Is there a way to have it where in a keybinding after it pastes the text it submits the text (presses enter for me). Lets just say as an example its google, so it pastes something into the google textbox and submits the search for me.
Code: Select all
if(commandDispatcher.focusedElement) {
goDoCommand("cmd_paste");
var e = commandDispatcher.focusedElement.ownerDocument.createEvent("KeyEvents");
e.initKeyEvent("keypress", true, true, null, false, false, false, false, KeyEvent.DOM_VK_ENTER, 0);
commandDispatcher.focusedElement.dispatchEvent(e);
}
Code: Select all
if(commandDispatcher.focusedElement &&
commandDispatcher.focusedElement.form) {
goDoCommand("cmd_paste");
commandDispatcher.focusedElement.form.submit();
}
That most likely referred to double clicking an non-custom entry in the keyconfig screen to duplicate it (the still misnamed context > Edit this key does the same). AutoCopy seems to be what you want.zillamanilla wrote:I was reading on earlier pages that you can create commands with a mouse click. I tried (but failed) in making a double click copy command. So I can double click a word and it copies it? How would that be done?
Try (tested against FoxLingo 2.2.5 but the id might change in the future)nettrotter wrote:I am using Foxlingo toolbar for translation.
Can you tell me what is the code to toggle on/off foxlingo toolbar?
Code: Select all
var toolbar = document.getElementById("foxlingo-toolbar-2-2-4");
toolbar.collapsed = !toolbar.collapsed;
document.persist(toolbar.id, "collapsed");
The code you've posted actually toggles that functionality on/off (the main code is in the "Initialization code" tab), just replace the last line withnettrotter wrote:I use a custom button " auto context menu on selection". which will pop up context menu immdiately when you highlight some text on webpages.Very handy, but sometimes i want to toggle off this button for momentary halt for this function.
and the code of this custom button as below:Code: Select all
var prefs=Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
try{
var cb_autoContextmenu = prefs.getBoolPref("cb_autoContextmenu" );
}catch(e){
prefs.setBoolPref("cb_autoContextmenu",true );
}
prefs.setBoolPref("cb_autoContextmenu", !prefs.getBoolPref("cb_autoContextmenu" ));
this.checked = prefs.getBoolPref("cb_autoContextmenu" );
then can you please tell me what is the code of toggle on/off "auto context menu on selection" function?
Thanks in advance.
Code: Select all
var button = document.getElementsByAttribute("label","Auto context menu on selection")[0];
if(button) button.checked = prefs.getBoolPref("cb_autoContextmenu" );
With Custom Buttons (but apparently not with Custom Buttons²) you can assign a Hotkey from the Button settings tab (it won't be "seen" by keyconfig as this seems to be handled by an event listener).
-
- Posts: 87
- Joined: June 26th, 2007, 6:17 pm
Re: keyconfig 20080929
dorando, you are really master in your field...all the scripts you suggest to me is in use. Thanks a lot.
-
- Posts: 17
- Joined: October 5th, 2008, 9:26 pm
Re: keyconfig 20080929
dorando, awesome, just awesome.
One more question, could this keyconfig execute more complicated scripts. Like for instance could I target a specific place on a webpage where text is located and have it execute a program like this:
1) Finds text by location and saves it as a variable (assuming I'm already on the webpage... could this text string be located by dominspector?)
2) Refreshes webpage
3) Finds same text string again and saves it as another variable
4) Compares both text strings to see if there is a change
4a) If no change exists then end script
4b) If change exists continue script
5) Change window
6) Paste changed textstring
One more question, could this keyconfig execute more complicated scripts. Like for instance could I target a specific place on a webpage where text is located and have it execute a program like this:
1) Finds text by location and saves it as a variable (assuming I'm already on the webpage... could this text string be located by dominspector?)
2) Refreshes webpage
3) Finds same text string again and saves it as another variable
4) Compares both text strings to see if there is a change
4a) If no change exists then end script
4b) If change exists continue script
5) Change window
6) Paste changed textstring
-
- Posts: 87
- Joined: June 26th, 2007, 6:17 pm
Re: keyconfig 20080929
QuickJava Allows quick enable and disable of Java and Javascript from toolbar. If I don't want to install extra addon, what code is in need to toggle on/off Java and javascript as firefow browser does.
-
- Posts: 1203
- Joined: January 9th, 2004, 9:57 am
- Contact:
Re: keyconfig 20080929
Something in the formzillamanilla wrote:
Code: Select all
var a = content.document.getElementById("DetailsTimeLeft").textContent;
BrowserReload();
function tempFunction(){
gBrowser.removeEventListener("DOMContentLoaded",tempFunction,false);
var b = content.document.getElementById("DetailsTimeLeft").textContent;
if(a != b) {
var enumerator =
Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator)
.getZOrderDOMWindowEnumerator("navigator:browser",true);
var newWindow;
if(enumerator.hasMoreElements()) enumerator.getNext();
if(enumerator.hasMoreElements()) newWindow = enumerator.getNext();
var focusedElement = newWindow.document.commandDispatcher.focusedElement;
if(!focusedElement) return;
newWindow.focus(); focusedElement.focus();
var editor = (focusedElement instanceof Components.interfaces.nsIDOMNSEditableElement) ? focusedElement.editor : null;
if(editor) {
editor instanceof Components.interfaces.nsIPlaintextEditor;
editor.insertText(b);
if(focusedElement.form) focusedElement.form.submit();
}
}
}
gBrowser.addEventListener("DOMContentLoaded",tempFunction,false);
Unless the text appears in a Plugin you should be able to find it with DOM Inspector.zillamanilla wrote:assuming I'm already on the webpage... could this text string be located by dominspector?
nettrotter wrote:QuickJava Allows quick enable and disable of Java and Javascript from toolbar. If I don't want to install extra addon, what code is in need to toggle on/off Java and javascript as firefow browser does.
Code: Select all
gPrefService.setBoolPref("javascript.enabled", !gPrefService.getBoolPref("javascript.enabled"));
gPrefService.setBoolPref("security.enable_java", !gPrefService.getBoolPref("security.enable_java"));
Code: Select all
gBrowser.docShell.allowJavascript = !gBrowser.docShell.allowJavascript;
gBrowser.docShell.allowPlugins = !gBrowser.docShell.allowPlugins;
-
- Posts: 17
- Joined: October 5th, 2008, 9:26 pm
Re: keyconfig 20080929
var a = content.document.getElementById("DetailsTimeLeft").textContent;
Absolutely outstanding!!!! I just have one question I've been trying to modify it a little bit to work for my specific instance. The problem I'm having is retrieving text within an HTML <code></code> tag. I tried using:could work, but since this is looking for something very specific (the "End time" on an ebay.com item) you need to adjust it for your use case (also note that it will only switch the window if the target window has a focusedElement).
"var a = content.document.getElementByTagName("code").textContent;"
But it doesn't seem to work. I think I'm missing something, I've been trying to figure it out, but for the life of me it just won't click right. I think it has to do with "innerHTML"
-
- Posts: 1203
- Joined: January 9th, 2004, 9:57 am
- Contact:
Re: keyconfig 20080929
zillamanilla wrote:The problem I'm having is retrieving text within an HTML <code></code> tag. I tried using:
"var a = content.document.getElementByTagName("code").textContent;"
But it doesn't seem to work. I think I'm missing something, I've been trying to figure it out, but for the life of me it just won't click right. I think it has to do with "innerHTML"
document.getElementsByTagName (common typo) returns a NodeList, content.document.getElementsByTagName("code")[0] should return the first one.
In this case textContent is likely not suitable, but for innerHTML you might want to strip/convert some content before pasting it, something like
Code: Select all
b = b.replace(/<br>/g,"\n").replace(/<.*?>/g,"").replace(/ /g," ").replace(/</g,"<");
-
- Posts: 17
- Joined: October 5th, 2008, 9:26 pm
Re: keyconfig 20080929
Oh man, I was sooo close! Thanks a ton!document.getElementsByTagName (common typo) returns a NodeList, content.document.getElementsByTagName("code")[0] should return the first one.
You know what, I'm that I'm thinking about it. Remember the code above I asked about if you could switch firefox windows then paste. I'm starting to wonder if changing tabs would be more efficient and faster. Could you change the code below so that it does the same exact thing but instead of going to another window it goes to another tab? I've been using BrowserNumberTabSelection(event, 1); to go to another tab. Would it work in this instance? I tried inputting it in for "var enumerator" but it didn't work. I was never good at programming. I need the code optimized for the fastest speed possible.
Code: Select all
var a = content.document.getElementById("DetailsTimeLeft").textContent;
BrowserReload();
function tempFunction(){
gBrowser.removeEventListener("DOMContentLoaded",tempFunction,false);
var b = content.document.getElementById("DetailsTimeLeft").textContent;
if(a != b) {
var enumerator =
Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator)
.getZOrderDOMWindowEnumerator("navigator:browser",true);
var newWindow;
if(enumerator.hasMoreElements()) enumerator.getNext();
if(enumerator.hasMoreElements()) newWindow = enumerator.getNext();
var focusedElement = newWindow.document.commandDispatcher.focusedElement;
if(!focusedElement) return;
newWindow.focus(); focusedElement.focus();
var editor = (focusedElement instanceof Components.interfaces.nsIDOMNSEditableElement) ? focusedElement.editor : null;
if(editor) {
editor instanceof Components.interfaces.nsIPlaintextEditor;
editor.insertText(b);
if(focusedElement.form) focusedElement.form.submit();
}
}
}
gBrowser.addEventListener("DOMContentLoaded",tempFunction,false);
-
- Posts: 115
- Joined: January 25th, 2005, 12:58 am
Re: keyconfig 20080929
I use the extension firesomething which changes the name in the titlebar (from mozilla firefox to whatever I like). However, this seems to disable keyconfig's functionality. Any shortcuts I make don't stay once I restart. I also use the extension titlebar tweaks, which also changes the titlebar. Anybody else have a similar issue?
-
- Posts: 17
- Joined: October 5th, 2008, 9:26 pm
Re: keyconfig 20080929
While in firefox press crtl+shift+F12. That will load up keyconfig. Double click any of the keyconfig items you want to use. When the new pop up appears (called keyconfig - Key Editor) look in the top right of this window for the check box that says "global", make sure you put a check mark in the box. Then press OK. Exit out of all your browsers, boot up firefox again and test out that keyconfig item you put that checkbox on. It should work now. It makes that item global to any and every firefox window you open up. That might solve your problem.ffuser17 wrote:I use the extension firesomething which changes the name in the titlebar (from mozilla firefox to whatever I like). However, this seems to disable keyconfig's functionality. Any shortcuts I make don't stay once I restart. I also use the extension titlebar tweaks, which also changes the titlebar. Anybody else have a similar issue?
-
- Posts: 115
- Joined: January 25th, 2005, 12:58 am
Re: keyconfig 20080929
Hmm... I thought I had it that way before and it didn't work. But now, it works perfectly... Thanks
-
- Posts: 17
- Joined: October 5th, 2008, 9:26 pm
Re: keyconfig 20080929
No Problem. You know what probably happened, you set everything but you didn't exit out of your browser and start up a new firefox window. I often do it too.