MozillaZine

keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted October 30th, 2013, 2:25 pm

bugblatter wrote:Hello all,
I was hoping someone here could help with this.
I have keyboard shortcut that opens a url from a bookmark by its keyword. It's worked forever but was recently broken by firefox 25:

Code: Select all
var url = getShortcutOrURI('mykeyword',{});
gBrowser.selectedTab = gBroser.addTab(url);


But getShortcutOrURI(url) has now been replaced by getShortcutOrURIAndPostData(url), which is returning some kind of object rather than just the plain url. I tried a simple fix but it didn't work. I googled it without much luck (relatively new issue I guess), though I noticed dorando mentioning patching his Search Type B extension for the same reason. Anyone have any ideas? Thanks for any help.

Weird. The object returned by getShortcutOrURIAndPostData doesn't have any properties at all. :-k

Try PlacesUtils.getURLAndPostDataForKeyword

Code: Select all
var url = PlacesUtils.getURLAndPostDataForKeyword('mykeyword')[0];
gBrowser.selectedTab = gBrowser.addTab(url); 
My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

bugblatter
 
Posts: 59
Joined: June 21st, 2005, 12:31 am

Post Posted October 31st, 2013, 2:03 am

Zoolcar9 wrote:
bugblatter wrote:Hello all,
I was hoping someone here could help with this.
I have keyboard shortcut that opens a url from a bookmark by its keyword. It's worked forever but was recently broken by firefox 25:

Code: Select all
var url = getShortcutOrURI('mykeyword',{});
gBrowser.selectedTab = gBroser.addTab(url);


But getShortcutOrURI(url) has now been replaced by getShortcutOrURIAndPostData(url), which is returning some kind of object rather than just the plain url. I tried a simple fix but it didn't work. I googled it without much luck (relatively new issue I guess), though I noticed dorando mentioning patching his Search Type B extension for the same reason. Anyone have any ideas? Thanks for any help.

Weird. The object returned by getShortcutOrURIAndPostData doesn't have any properties at all. :-k

Try PlacesUtils.getURLAndPostDataForKeyword

Code: Select all
var url = PlacesUtils.getURLAndPostDataForKeyword('mykeyword')[0];
gBrowser.selectedTab = gBrowser.addTab(url);  


Thanks! That seems to have done the trick.

kramb21
 
Posts: 5
Joined: October 31st, 2013, 2:05 am

Post Posted October 31st, 2013, 2:09 am

Hello,

I have some trouble with keyconfig since the last update of FF 25.

Code: Select all
BrowserOpenTab();
loadURI(getShortcutOrURI('google.com',{}));


This code doesn't work anymore, it just open a new tab, but doesn't load Google.
I hope someone can help me :oops:

Thanks!

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted October 31st, 2013, 6:27 am

@kramb21, see my post above.
My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

kramb21
 
Posts: 5
Joined: October 31st, 2013, 2:05 am

Post Posted October 31st, 2013, 6:51 am

I actully tried, but I'm not a developer, but just a stupid user and it didn't work.
How can I realize it? I just want to open Google in a new tab, that's it...

[codeBrowserOpenTab();
loadURI(PlacesUtils.getURLAndPostDataForKeyword('https://www.google.com/')[0]);
_content.focus(document.va); [/code]

It just opens a blank tab...

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted October 31st, 2013, 7:04 am

What if you use loadURI('google.com')?

Code: Select all
BrowserOpenTab();
loadURI('google.com'); 
My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

kramb21
 
Posts: 5
Joined: October 31st, 2013, 2:05 am

Post Posted November 4th, 2013, 6:47 am

I'll try that later. Thanks for the help!

WCityMike
 
Posts: 63
Joined: February 29th, 2004, 10:28 am
Location: Chicago, Illinois

Post Posted November 9th, 2013, 7:48 pm

I don't claim authorship over any of them -- most of them were courteous of kind people in this forum, especially dorando -- but thought I'd post these in case it was of interest to any of you, as well as to have a backup of them somewhere external:

Close Other Tabs
Ctrl-Shift-C
Code: Select all
gBrowser.removeAllTabsBut(gBrowser.mCurrentTab);


Close Tab, Remove Bookmark, Move to Left
Ctrl-Shift-W
Code: Select all
var itemId = PlacesUtils.getMostRecentBookmarkForURI(gBrowser.currentURI);
if(itemId != -1)
   PlacesUtils.bookmarks.removeItem(itemId);
gBrowser.removeTab(gBrowser.mCurrentTab)


Hide It All
Ctrl-F11
Code: Select all
var pref = "extensions.tabmix.hideTabbar";
gBrowser.mPrefs.setIntPref(pref, gBrowser.mPrefs.getIntPref(pref) == 0 ? 2 : 0);
var toolbar = document.getElementById("PersonalToolbar");
toolbar.collapsed = !toolbar.collapsed;
document.persist(toolbar.id, "collapsed");
var toolbar = document.getElementById("nav-bar");
toolbar.collapsed = !toolbar.collapsed;
document.persist(toolbar.id, "collapsed");
var toolbar = document.getElementById("toolbar-menubar");
toolbar.collapsed = !toolbar.collapsed;
document.persist(toolbar.id, "collapsed");
var toolbar = document.getElementById("status-bar");
toolbar.collapsed = !toolbar.collapsed;
document.persist(toolbar.id, "collapsed");
var toolbar = document.getElementById("addon-bar");
toolbar.collapsed = !toolbar.collapsed;
document.persist(toolbar.id, "collapsed");


Lock and Protect Tab
Ctrl-Shift-L
Code: Select all
gBrowser.freezeTab(gBrowser.mCurrentTab);
if(gBrowser.mCurrentTab.pinned)
 gBrowser.unpinTab(gBrowser.mCurrentTab);
else
 gBrowser.pinTab(gBrowser.mCurrentTab);


Open "Mail" Folder
Ctrl-Shift-M
Code: Select all
document.getElementById("PersonalToolbar").getElementsByAttribute("label","Mail")[0].open = true;


Open Bookmarks Inbox
Ctrl-B
Code: Select all
var folder = "Inbox";

var result = PlacesUtils.getFolderContents(PlacesUtils.placesRootId, true);

var place = findFolder(result.root, folder);

function findFolder(rootNode, title) {
 rootNode.containerOpen = true;

 for (var i = 0; i < rootNode.childCount; i ++) {
  var node = rootNode.getChild(i).QueryInterface(Ci.nsINavHistoryContainerResultNode);
  if(node.title == title) return node.itemId;
  if(node.hasChildren) {
   var ret = findFolder(node, title);
   if(ret) return ret;
  }
 }

 rootNode.containerOpen = false;
}

var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
var organizer = wm.getMostRecentWindow("Places:Organizer");

if (!organizer) {
 organizer = openDialog("chrome://browser/content/places/places.xul",
             "", "chrome,toolbar=yes,dialog=no,resizable", folder);
 organizer.addEventListener("load", function(){
  organizer.removeEventListener(event.type, arguments.callee, true);
  organizer.PlacesUIUtils.leftPaneQueries[folder] = place;
 }, true);
} else {
 organizer.PlacesUIUtils.leftPaneQueries[folder] = place;
 organizer.PlacesOrganizer.selectLeftPaneQuery(folder);
 organizer.focus();
}


Pipe Webpage to Readability
Ctrl-Shift-B
Code: Select all
var url = PlacesUtils.getURLAndPostDataForKeyword('read')[0];
if(window.loadURI) loadURI(url);


Post to Facebook
Ctrl-Shift-R
Code: Select all
var url = PlacesUtils.getURLAndPostDataForKeyword('facepost')[0];
if(window.loadURI) loadURI(url);


Post to RTM
Ctrl-Shift-U
Code: Select all
var url = PlacesUtils.getURLAndPostDataForKeyword('rtmurl')[0];
if(window.loadURI) loadURI(url);


Quick Bookmark This Page
Ctrl-D
Code: Select all
try {
   var tbbookmarks = Components.classes['@mozilla.org/browser/nav-bookmarks-service;1']
                .getService(Components.interfaces.nsINavBookmarksService);
   var uri = Components.classes['@mozilla.org/network/io-service;1']
           .getService(Components.interfaces.nsIIOService)
           .newURI(window.content.document.location.href, null, null);
   var title = window.content.document.title;
   if (title == "") {
      title = window.content.document.location.href;
   }
   tbbookmarks.insertBookmark(tbbookmarks.bookmarksMenuFolder, uri,
            tbbookmarks.DEFAULT_INDEX, window.content.document.title);
} catch (e) {
   var page = gBrowser.mCurrentBrowser;
   var url = page.currentURI.spec;
   var charset = page.currentURI.originCharset;
   var name = page.contentTitle;
   rFolder = RDF.GetResource("NC:BookmarksRoot");
   RDF = Components.classes['@mozilla.org/rdf/rdf-service;1']
        .getService(Components.interfaces.nsIRDFService);
   BMDS = RDF.GetDataSource("rdf:bookmarks");
   rSource = BMDS.createBookmark(name, url, null, null, charset, false, "");
   var selection = BookmarksUtils.getSelectionFromResource(rSource);
   var target = BookmarksUtils.getTargetFromFolder(rFolder);
   BookmarksUtils.insertAndCheckSelection("newbookmark", selection, target);
}

rbfye14
 
Posts: 26
Joined: April 9th, 2012, 8:23 am

Post Posted November 10th, 2013, 2:27 am

After the last update to FF 25 there is a lot of errors in error console:

props is undefined @ chrome://keyconfig/content/keyconfig.js:421
and
TypeError: props is undefined @ chrome://keyconfig/content/keyconfig.js:421

What is going wrong?

Zoolcar9

User avatar
 
Posts: 2225
Joined: November 9th, 2004, 6:45 pm
Location: Jakarta, Indonesia (UTC+7)

Post Posted November 10th, 2013, 3:31 am

rbfye14 wrote:What is going wrong?

Probably bug 407956.
My Firefox information | Add-ons | GitHub

"With great power, comes great desire to show it off."

tonymec

User avatar
 
Posts: 731
Joined: October 15th, 2004, 2:58 am
Location: Ixelles (Brussels Capital Region, Belgium)

Post Posted November 11th, 2013, 9:38 am

WCityMike: I suppose the key assignations are only examples? In SeaMonkey at least, Shift+Ctrl+W is by default "Close Window", which I have found useful as part of a workaround for bug 916631, see bug 916631 comment #39. (This bug is now VERIFIED FIXED but there has been no SeaMonkey trunk build for Linux since some time before the fix landed.)
Best regards,
Tony

WCityMike
 
Posts: 63
Joined: February 29th, 2004, 10:28 am
Location: Chicago, Illinois

Post Posted November 11th, 2013, 11:51 am

tonymec wrote:WCityMike: I suppose the key assignations are only examples?


Yup, just what I'm using.

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

Post Posted November 12th, 2013, 12:58 am

Anyone know of a way to add a keyconfig shortcut that takes you up one level in the URL? eg: example.com/support/ticket/ becomes example.com/support/

Something without adding another addon would be great, like a userscript if Firefox doesn't have an existing internal command :D

onemen

User avatar
 
Posts: 1130
Joined: October 15th, 2004, 7:48 am

Post Posted November 12th, 2013, 1:24 am

Springtime wrote:Anyone know of a way to add a keyconfig shortcut that takes you up one level in the URL? eg: example.com/support/ticket/ becomes example.com/support/

Something without adding another addon would be great, like a userscript if Firefox doesn't have an existing internal command :D


Code: Select all
function goup_getUpUrl(url) {
    var matches, origUrl = url;
    // trim filename (this makes subdriectory digging easier)
    matches = url.match(/(^.*\/)(.*)/);
    if(!matches) return null; //only fails if "url" has no /'s
    url = matches[1];
    if(url!=origUrl && !/(index|main)\.(php3?|html?)/i.test(url))
      return url;
    // dig through subdirs
    matches = url.match(/^([^\/]*?:\/\/.*\/)[^\/]+?\//);
    if(matches) return matches[1];
    // we've reach (ht|f)tp://foo.com/, climb up through subdomains
    // split into protocol and domain
    matches = url.match(/([^:]*:\/\/)?(.*)/);
    var protocol = matches[1], domain = matches[2];
    matches = domain.match(/^[^\.]*\.(.*)/);
    if(matches) return (protocol+matches[1]);
    return null;
}

var loc = content.document.location, pro = loc.protocol;
if(/^ftp|http|https$/.test(pro)){
  var up = goup_getUpUrl(loc.href);
  if(up)
    openUILink(up);
}

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

Post Posted November 12th, 2013, 1:34 am

onemen wrote:Awesome code


Thank you so much! It's great when one addon can handle everything, rather than adding further addons.

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 4 guests