keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
Post Reply
dorando
Posts: 1203
Joined: January 9th, 2004, 9:57 am
Contact:

Re: keyconfig 20110522

Post by dorando »

chirpy_7 wrote:A couple of hours ago (at most a few days ago) I noticed a change on GOOGLE: the following (for opening individual GOOGLE search results in a new (and/or the current) tab) doesn't seem to work anymore, the "nodes" must have changed slightly:

Code: Select all

if(window.content.location.href.match(/^http(s)?://www.google.(com|fr)/search/))
{
var 
nodes content.document.evaluate('//h3/a[@class]'content.documentnull7null);
gBrowser.addTab(nodes.snapshotItem(0));
The (10 standard) links (in GOOGLE) seem to have this

Code: Select all

<h3 class="r" style="display: inline;"
around them, but simply (naively) replacing "a" with "r" (in the keyconfig code above) didn't do the trick...

Any pointers how to fix the code?
Try

Code: Select all

var nodes content.document.querySelectorAll("h3.r a, h3 a.l");
gBrowser.addTab(nodes[0]); 


Amsuke wrote:Arrow Up:

Code: Select all

if(commandDispatcher.focusedWindow.document.designMode == "on")
 
goDoCommand("cmd_lineNext");

var 
target commandDispatcher.focusedElement;
if(!(
target instanceof HTMLInputElement && (target.type == "text" || target.type == "password")))
 
commandDispatcher.focusedWindow.scrollByLines(-4); 
The problem is that certain webmail interfaces are having problems with this - whereby the up arrow key acts like the down arrow key.
Try

Code: Select all

if(commandDispatcher.focusedWindow.document.designMode == "on")
 
goDoCommand("cmd_linePrevious");

var 
target commandDispatcher.focusedElement;
if(!(
target instanceof HTMLInputElement && (target.type == "text" || target.type == "password")))
 
commandDispatcher.focusedWindow.scrollByLines(-4); 
Support mozilla.dorando.at through donations/contributions.
Amsuke
Posts: 60
Joined: April 3rd, 2010, 8:23 am

Re: keyconfig 20110522

Post by Amsuke »

Thanks, Dorando! That fixed it perfectly!
Rava
Posts: 18
Joined: May 9th, 2008, 1:26 am

Re: keyconfig 20110522

Post by Rava »

dorando, trying to install keyconfig for Linux Thunderbird 17.x using the build in mechanism fails:

Image

Any idea why that might be?
yours
Rava
Brummelchen
Posts: 4480
Joined: March 19th, 2005, 10:51 am

Re: keyconfig 20110522

Post by Brummelchen »

its not listed = not present on AMO - such simple
only here http://mozilla.dorando.at/
Zoolcar9
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)
Contact:

Re: keyconfig 20110522

Post by Zoolcar9 »

 
@Rava, here's how to install keyconfig on Thunderbird.

dorando wrote:In the Browser: Context Menu > Save Link As…
In Thunderbird: Tools > Add-ons > Button next to the Search box > Install Add-on From File…
Zoolcar9 wrote:You can also drag keyconfig.xpi link from Firefox window onto Add-ons Manager in Thunderbird window.

viewtopic.php?p=12693017#p12693017
My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."
firefoxuse
Posts: 1086
Joined: November 8th, 2011, 12:06 pm

Re: keyconfig 20110522

Post by firefoxuse »

can you tell me please the code for 'open link in background tab' ?
I need to click on a link with CTRL+SHIFT held down and open that link in the background
User avatar
Ander
Posts: 74
Joined: February 3rd, 2004, 12:02 am
Location: Canada

Re: keyconfig 20110522

Post by Ander »

I just wanted to thank you for this fabulous add-on, which still works impressively well with Firefox 20!

It's hard to believe FF includes no native way to enable-disable its built-in keyboard shortcuts (which are often presumptuously inconvenient, such as using the traditional text-editing keys Ctrl+I and Ctrl+B for Bookmark-related tasks).

It's also hard to believe that FF's add-on site doesn't seem to host any third-party code that lets you do it, including Keyconfig. (Have you submitted it there? Did they turn you down for some reason? Go figure.)

Anyway, a grateful sigh of relief here. Cheers, Ander
dorando
Posts: 1203
Joined: January 9th, 2004, 9:57 am
Contact:

Re: keyconfig 20110522

Post by dorando »

firefoxuse wrote:can you tell me please the code for 'open link in background tab' ?
I need to click on a link with CTRL+SHIFT held down and open that link in the background
For focused links try

Code: Select all

if(commandDispatcher.focusedElement && commandDispatcher.focusedElement.href)
 
openLinkIn(commandDispatcher.focusedElement.href"tab", { inBackgroundtrue }); 
, for hovered links try

Code: Select all

if(XULBrowserWindow.overLink)
 
openLinkIn(XULBrowserWindow.overLink"tab", { inBackgroundtrue }); 

Ander wrote:Have you submitted it there?
No.
Support mozilla.dorando.at through donations/contributions.
rbfye14
Posts: 26
Joined: April 9th, 2012, 8:23 am

Re: keyconfig 20110522

Post by rbfye14 »

Is it possible to get the size of the image (in kb, not dimensions) by it's ID?
morat
Posts: 6429
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

rbfye14 wrote:Is it possible to get the size of the image (in kb, not dimensions) by it's ID?

Try this:

Code: Select all

function formatNumber(number) {
  return (+number).toLocaleString();
}
var cacheService = Components.classes["@mozilla.org/network/cache-service;1"].
  getService(Components.interfaces.nsICacheService);
var httpCacheSession = cacheService.createSession("HTTP", 0, true);
httpCacheSession.doomEntriesIfExpired = false;
var image = content.document.getElementsByTagName("img")[0];
// var image = content.document.getElementById("thingamajig");
var url = image.src;
var cacheKey = url.replace(/#.*$/, "");
try {
  var cacheEntryDescriptor = httpCacheSession.openCacheEntry(cacheKey,
    Components.interfaces.nsICache.ACCESS_READ, false);
  var imageSize = cacheEntryDescriptor.dataSize;
  var kbSize = Math.round(imageSize / 1024 * 100) / 100;
  alert(formatNumber(kbSize) + " KB (" + formatNumber(imageSize) + " bytes)");
} catch (e) {
  alert("Unknown (not cached)");
}
rbfye14
Posts: 26
Joined: April 9th, 2012, 8:23 am

Re: keyconfig 20110522

Post by rbfye14 »

morat wrote:
rbfye14 wrote:Is it possible to get the size of the image (in kb, not dimensions) by it's ID?

Try this:

Code: Select all

function formatNumber(number) .......
.......

morat,
It doesn't work for me... I persistently get an alert "Unknown (not cached)"
morat
Posts: 6429
Joined: February 3rd, 2009, 6:29 pm

Re: keyconfig 20110522

Post by morat »

@rbfye14

The openCacheEntry method now fails if it is called on the main thread.

Code: Select all

function openCacheEntry(key, cb) {
  var tries = 0;
  var listener = {
    onCacheEntryAvailable: function (entry, access, status) {
      if (entry || tries == 1) {
        cb(entry);
      } else {
        tries++;
        ftpCacheSession.asyncOpenCacheEntry(key, ACCESS_READ, this, true);
      }
    }
  }
  httpCacheSession.asyncOpenCacheEntry(key, ACCESS_READ, listener, true);
}
function formatNumber(number) {
  return (+number).toLocaleString();
}
var ACCESS_READ = Components.interfaces.nsICache.ACCESS_READ;
var cacheService = Components.classes["@mozilla.org/network/cache-service;1"].
  getService(Components.interfaces.nsICacheService);
var httpCacheSession = cacheService.createSession("HTTP", 0, true);
httpCacheSession.doomEntriesIfExpired = false;
var ftpCacheSession = cacheService.createSession("FTP", 0, true);
ftpCacheSession.doomEntriesIfExpired = false;
var image = content.document.getElementsByTagName("img")[0];
// var image = content.document.getElementById("thingamajig");
var url = image.src;
var cacheKey = url.replace(/#.*$/, "");
openCacheEntry(cacheKey, function (cacheEntry) {
  if (cacheEntry) {
    var imageSize = cacheEntry.dataSize;
    var kbSize = Math.round(imageSize / 1024 * 100) / 100;
    alert(formatNumber(kbSize) + " KB (" + formatNumber(imageSize) + " bytes)");
  } else {
    alert("Unknown (not cached)");
  }
});

reference:

http://mxr.mozilla.org/mozilla-release/ ... ageInfo.js
Zoolcar9
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)
Contact:

Re: keyconfig 20110522

Post by Zoolcar9 »

Ander wrote:It's also hard to believe that FF's add-on site doesn't seem to host any third-party code that lets you do it

Almost ALL add-ons on addons.mozilla.org ARE third party.
My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."
rbfye14
Posts: 26
Joined: April 9th, 2012, 8:23 am

Re: keyconfig 20110522

Post by rbfye14 »

morat wrote:The openCacheEntry method now fails if it is called on the main thread.

Code: Select all

function openCacheEntry(key, cb) {
  var tries = 0;
  var listener =
.................

morat
This works like a charm :D
Thanks a lot!
Cattleya
Posts: 57
Joined: October 7th, 2010, 11:14 pm

Re: keyconfig 20110522

Post by Cattleya »

Hi dorando :)
Can you help me ? I want a hotkey to subscrible current page to RSS Feed, like Menu -> Bookmark -> Subscrible to This Page did :)

Hope you can help me, many thank :)
Post Reply