keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
Post Reply
FFnut
Posts: 1
Joined: October 4th, 2016, 7:35 am

Re: keyconfig 20110522

Post by FFnut »

New to this extension and find it indispensable.

Looking now for a shortcut that jumps to prev/next account inbox in the folder pane. With several accounts, that would be much better than navigating with arrow keys.

Glad to see active support ongoing here, many thanks. Any chance someone would fork the project to a 'keyconfig2' to update?
morat
Posts: 6437
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@FFnut

If you select a folder that is an inbox, then the shortcut selects the next inbox folder.

If you select a folder that isn't an inbox, then the shortcut selects the inbox folder in the selected account.

If you select a folder in the "Local Folders" account, then the shortcut selects the first inbox folder.

Try this:

Code: Select all

var accountManager = Components.classes["@mozilla.org/messenger/account-manager;1"].
  getService(Components.interfaces.nsIMsgAccountManager);
var allServers = accountManager.allServers;
var inboxFolders = [];
for (var i = 0; i < allServers.length; i++) {
  var currentServer = allServers.
    queryElementAt(i, Components.interfaces.nsIMsgIncomingServer);
  var inboxFolder = currentServer.rootFolder.
    getFolderWithFlags(Components.interfaces.nsMsgFolderFlags.Inbox);
  if (inboxFolder) {
    inboxFolders.push(inboxFolder);
  }
}
function next(i) {
  var index = i + 1;
  index = index % inboxFolders.length;
  return index;
}
function previous(i) {
  var index = i;
  if (index == 0) {
    index = inboxFolders.length;
  }
  index = index - 1;
  return index;
}
var folder = GetFirstSelectedMsgFolder();
if (folder.getFlag(Components.interfaces.nsMsgFolderFlags.Inbox)) {
  for (var i = 0; i < inboxFolders.length; i++) {
    var inboxFolder = inboxFolders[i];
    if (inboxFolder.URI == folder.URI) {
         gFolderTreeView.selectFolder(inboxFolders[next(i)]);
      // gFolderTreeView.selectFolder(inboxFolders[previous(i)]);
      break;
    }
  }
} else {
  var inboxFolder = folder.rootFolder.
    getFolderWithFlags(Components.interfaces.nsMsgFolderFlags.Inbox);
  if (inboxFolder) {
    gFolderTreeView.selectFolder(inboxFolder);
  } else {
    gFolderTreeView.selectFolder(inboxFolders[0]);
  }
}
bege
Posts: 153
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Re: keyconfig 20110522

Post by bege »

FFnut wrote: Any chance someone would fork the project to a 'keyconfig2' to update?
I am not sure what you mean. Do you use the original extension from here?: http://mozilla.dorando.at
There is an updated extension here already: https://addons.mozilla.org/en-us/firefo ... src=search
abcuser
Posts: 261
Joined: March 12th, 2007, 11:19 pm

Re: keyconfig 20110522

Post by abcuser »

Hi,
I would like to create a keyboard shortcut to open a new URL in current tab and set tab background color to blue (and maybe set tab color font to red).

To open new page in current tab:

Code: Select all

gBrowser.loadURI('http://www.example.com');
How to change a tab color of current tab?

See details:
https://i.imgur.com/94lZIAG.png

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

Re: keyconfig 20110522

Post by morat »

@abcuser

Here is how to toggle the tab background color of the middle of the tab.

Code: Select all

var ios = Components.classes["@mozilla.org/network/io-service;1"].
  getService(Components.interfaces.nsIIOService);
var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].
  getService(Components.interfaces.nsIStyleSheetService);
var css = ".tab-background-middle[visuallyselected=true] { " +
  "background-color: orange !important; }";
var uri = ios.newURI("data:text/css," + encodeURIComponent(css), null, null);
if (sss.sheetRegistered(uri, sss.USER_SHEET)) {
  sss.unregisterSheet(uri, sss.USER_SHEET);
} else {
  sss.loadAndRegisterSheet(uri, sss.USER_SHEET);
}
It is really complicated to change the tab background color of the start and end graphics.

view-source:chrome://browser/skin/browser.css
view-source:chrome://browser/skin/tabbrowser/tab-selected-start.svg
view-source:chrome://browser/skin/tabbrowser/tab-selected-end.svg

http://en.wikipedia.org/wiki/Scalable_Vector_Graphics
abcuser
Posts: 261
Joined: March 12th, 2007, 11:19 pm

Re: keyconfig 20110522

Post by abcuser »

morat, thanks for help. For my need coloring middle of the tab is good enough solution.

Actually what I need is little bit more complicated. I actually need to switch between two URL addresses with different key shortcuts. Like:
1. CTRL+ALT+A to load sampleA.example.com and mark tab background color to red
2. CTRL+ALT+B to load sampleB.example.com and reset tab background to default color

I split your "if" part of the code into two junks "setting background color" and "resetting it".

Code for 1.

Code: Select all

gBrowser.loadURI('http://sampleA.example.com/');
var ios = Components.classes["@mozilla.org/network/io-service;1"].
  getService(Components.interfaces.nsIIOService);
var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].
  getService(Components.interfaces.nsIStyleSheetService);
var css = ".tab-background-middle[visuallyselected=true] { " +
  "background-color: orange !important; }";
var uri = ios.newURI("data:text/css," + encodeURIComponent(css), null, null);
sss.loadAndRegisterSheet(uri, sss.USER_SHEET);
Code for 2:

Code: Select all

gBrowser.loadURI('http://sampleB.example.com');
var ios = Components.classes["@mozilla.org/network/io-service;1"].
  getService(Components.interfaces.nsIIOService);
var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].
  getService(Components.interfaces.nsIStyleSheetService);
var css = ".tab-background-middle[visuallyselected=true] { " +
  "background-color: orange !important; }";
var uri = ios.newURI("data:text/css," + encodeURIComponent(css), null, null);
sss.unregisterSheet(uri, sss.USER_SHEET);
The above code works fine and it does what I want when shortcut is pressed, but... But little problem appeared. By accident I pressed CTRL+ALT+A twice, and now I see that I have to press CTRL+ALT+B twice to reset background color to default. If I press CTRL+ALT+A three times, then I need to press CTRL+ALT+B also three times to accomplish reset affect.

How to make this work if by accident multiple times one shortcut is pressed?
morat
Posts: 6437
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@abcuser

Try these:

* Code for 1

Code: Select all

var ios = Components.classes["@mozilla.org/network/io-service;1"].
  getService(Components.interfaces.nsIIOService);
var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].
  getService(Components.interfaces.nsIStyleSheetService);
var css = ".tab-background-middle[visuallyselected=true] { " +
  "background-color: orange !important; }";
var uri = ios.newURI("data:text/css," + encodeURIComponent(css), null, null);
if (!sss.sheetRegistered(uri, sss.USER_SHEET)) {
  gBrowser.loadURI("http://sampleA.example.com/");
  sss.loadAndRegisterSheet(uri, sss.USER_SHEET);
}
* Code for 2

Code: Select all

var ios = Components.classes["@mozilla.org/network/io-service;1"].
  getService(Components.interfaces.nsIIOService);
var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].
  getService(Components.interfaces.nsIStyleSheetService);
var css = ".tab-background-middle[visuallyselected=true] { " +
  "background-color: orange !important; }";
var uri = ios.newURI("data:text/css," + encodeURIComponent(css), null, null);
if (sss.sheetRegistered(uri, sss.USER_SHEET)) {
  gBrowser.loadURI("http://sampleB.example.com");
  sss.unregisterSheet(uri, sss.USER_SHEET);
}
FYI,

The code changes the color of the selected tab. The code doesn't change the color of an individual tab, like the ColorfulTabs extension.

ColorfulTabs
http://addons.mozilla.org/firefox/addon/1368

That functionality would be too much trouble to code.
abcuser
Posts: 261
Joined: March 12th, 2007, 11:19 pm

Re: keyconfig 20110522

Post by abcuser »

morat, thanks a lot. Your code works exactly like I want.
Game-R
Posts: 23
Joined: October 6th, 2004, 7:21 pm

Re: keyconfig 20110522

Post by Game-R »

Hi there,
I've been an avid user of keyconfig since almost the early Firefox 3 days and have been wiring up a lot of shortcuts with custom scripts that I've found in this forum
I've also made the transition to Dorando Keyconfig (https://addons.mozilla.org/en-US/firefo ... keyconfig/) earlier this year when keyconfig has started losing its reliability.

Lately however, I've noticed that all of my custom scripts, listed below, are all dead! Absolutely none of the previous codes posted in the forums here for DTA, ShowPictures extensions or even the undoCloseTab() would work.
Recently I had also brought up issues with of Firefox Developer Tools hijacking custom set keyboard shortcuts: https://bugzilla.mozilla.org/show_bug.cgi?id=1299431#c3
In the discussion, the developers mentioned the existence of a "new key shortcut module" being developed.

Has there been a change in Firefox's API for keyboard shortcuts or is the keyconfig extension and its derivatives well and truly dead??

Code: Select all

undoCloseTab();

Code: Select all

document.getElementById("dtaCtxDTA").doCommand();

Code: Select all

var node =
 document.getElementById("dta-tb-all") ||
 gNavToolbox.palette.getElementsByAttribute("id","dta-tb-all")[0];
var evt = document.createEvent("XULCommandEvent");
evt.initCommandEvent("command", true, true, window, 0, false, false, false, false, null);
node.dispatchEvent(evt); 

Code: Select all

SPOV.doShowAllPictures(0);

Code: Select all

var alertsService = Components.classes["@mozilla.org/alerts-service;1"]
.getService(Components.interfaces.nsIAlertsService);
ShowPicture.doPicturesOnOff();
alertsService.showAlertNotification(null, "keyconfig", ShowPicture._prefs.getIntPref('permissions.default.image') == 1 ? "Show All Pictures" : "Hide All Pictures");
morat
Posts: 6437
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Game-R

I don't use trlkly's extension, so I can't help with that.

The undoCloseTab command still works.

The DownThemAll! code still works.

The "DownThemAll! (All Tabs)" code still works if I put the DownThemAll! button on the toolbar.

The "Show All Pictures" code still works.

DownThemAll!
http://addons.mozilla.org/firefox/addon/201

Show Picture
http://addons.mozilla.org/firefox/addon/3664

Extension signing hack
http://wiki.mozilla.org/Add-ons/Extension_Signing
http://www.largrizzly.net/firefox.html

Keyconfig 20110522 (cannot install without hack)
Firefox Portable 49.0.2
Windows 7 SP1 32-bit
Bananasik
Posts: 12
Joined: November 7th, 2016, 3:10 am

Re: keyconfig 20110522

Post by Bananasik »

Hello.
Is there any way to select a tab, like CTRL+click on tab do?
morat
Posts: 6437
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Bananasik

Try these:

Code: Select all

// select new tab
gBrowser.selectedTab = gBrowser.addTab("http://www.google.com/");

// select first tab
gBrowser.selectTabAtIndex(0, event);

// select second tab
gBrowser.selectTabAtIndex(1, event);

// select third tab
gBrowser.selectTabAtIndex(2, event);

// select last tab
gBrowser.selectTabAtIndex(-1, event);

// select next tab with wrap
gBrowser.tabContainer.advanceSelectedTab(1, true);

// select previous tab with wrap
gBrowser.tabContainer.advanceSelectedTab(-1, true);
abcuser
Posts: 261
Joined: March 12th, 2007, 11:19 pm

Re: keyconfig 20110522

Post by abcuser »

Hi,
I am preparing special purpose Fifeox Portable 45 ESR for our enterprise. I would like to disable as much of keyboard shortcuts as possible. I have managed to do so, but some of the shortcuts can't be disabled (or I can't figure it out how to disable them).

I have asked general question on Firefox Support forum http://forums.mozillazine.org/viewtopic ... p=14719930 and got reply: that this could be done using Keyconfig add-on.

I have tried to disable:
a) CTRL+SHIFT+C
b) CTRL+SHIFT+K
c) CTRL+SHIFT+S
d) SHIFT+F7
all of them are Web Development shortcuts and Keyconfig returns warning that this shortcuts are already used and may not be applied. And I see they are not accepted. Is there something special I have to perform to disable this shortcuts?

Thanks
Bananasik
Posts: 12
Joined: November 7th, 2016, 3:10 am

Re: keyconfig 20110522

Post by Bananasik »

morat, thanks for help, but it isn`t what i want.
I need selection, not focus.
Like this one http://i.imgur.com/usZ7DgJ.gif
Tab selected with CTRL+click action. Needs code only for a tab that is being watched at the moment.
morat
Posts: 6437
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@Bananasik

I don't understand. AFAIK, there is no ctrl left-click on tab shortcut.

Are you using the Tab Mix Plus extension?

http://support.mozilla.org/kb/mouse-sho ... mmon-tasks
http://superuser.com/questions/434216
Post Reply