MozillaZine

keyconfig 20110522

Announce and Discuss the Latest Theme and Extension Releases.
troypst
 
Posts: 16
Joined: March 15th, 2013, 5:19 am

Post Posted April 25th, 2014, 4:42 pm

Hi, I have this code
Code: Select all
var bookmarksService = Components.classes["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Components.interfaces.nsINavBookmarksService);
var dateTime = (new Date()).toLocaleFormat("%Y/%m/%d %H:%M:%S");
var strPrefPrefix = "Bookmarks at: ";

//var targetFolder = bookmarksService.bookmarksMenuFolder;
//var targetFolder = bookmarksService.toolbarFolder;
var targetFolder = bookmarksService.unfiledBookmarksFolder;

targetFolder = bookmarksService.createFolder(targetFolder,strPrefPrefix + dateTime,-1);
document.getElementById("content").browsers.forEach(function (b)
 { var webNav = b.webNavigation;
   var url = webNav.currentURI.spec;
   try { var title = webNav.document.title || url; }
   catch (e) { title = url; }
   var id = bookmarksService.insertBookmark(targetFolder,webNav.currentURI,-1,title); } );

that I've stolen from "Bookmark Current Tab Set" add-on and modified to quickly save all tabs of a window in my bookmarks. How do I change it to save all tabs of ALL WINDOWS?
Thanks.

Cattleya
 
Posts: 57
Joined: October 7th, 2010, 11:14 pm

Post Posted April 28th, 2014, 5:09 pm

Hi dorando, Morat, Zoolcar
Long time no see and I really need you guys help again :)

I know that a extension called "CacheViewer" can delete specific Firefox cache: https://addons.mozilla.org/en-us/firefo ... cheviewer/ (Open CacheViewer, select cache entry that you want to clear -> Right Click -> Delete)

How can I do that with a Keyconfig command ? Example I want to delete "http://example.com/javascript/time.js" from FIrefox cache.
I really want to do that because I'm using BetterCache addons, it speed up my FIrefox (even some hidden connection it still can force it get cached) but sometimes I have to clear some cache entries like ( "http://example.com/javascript/time.js" , "http://example.com/javascript/work.js"...) but it is not really fast using CacheViewer, I think if I can create a Keyconfig shortcut and clear them then it will be faster.

Many thank!

I read CacheViewer source code but don't know how to port it to Keyconfig and make it only delete cache URL like cache.delete("http://example.com/javascript/time.js"); or something like that.

Code: Select all
_delSelEntry: function CV__delSelEntry(){
      if (this._delEntryList.length == 0)
      {
         this._updateUI();
         return
      }
      entry = this._delEntryList.shift();
      var key = this._rdf.getLiteralProperty(entry, this._rdf.NS_CACHEVIEWER+"key");
      var client = this._rdf.getLiteralProperty(entry, this._rdf.NS_CACHEVIEWER+"clnt");
      var stream = this._rdf.getIntProperty(entry, this._rdf.NS_CACHEVIEWER+"strm");
      var self = this;
      this._asyncOpenCacheEntry(key, client, stream,{
         onCacheEntryAvailable:function(descriptor, accessGranted, status) {
            if(status != Components.results.NS_OK)
            {
               self._delSelEntry();
               return;
            }
            try {
            descriptor.doom();
            } catch(e) {
               dump(e+"\n");
            }
            descriptor.close();
            // moved from _updateUI
            self._rdf.removeResource(entry, self._rdf.getContainer(self._rdf.RDF_ITEM_ROOT));
            if (self._tree.ref == self._rdf.RDF_ITEM_SEARCH)
               self._rdf.removeResource(entry, self._rdf.getContainer(self._rdf.RDF_ITEM_SEARCH));
            self._DBConn.executeSimpleSQL("DELETE FROM cacheentries WHERE id = "+entry.Value);
            self._delSelEntry();
         }
      }
      );
   },
   deleteCache: function CV_deleteCache() {
      if (this._isLoading) return;
      
      this._delEntryList = [];
      var rangeCount = this._tree.view.selection.getRangeCount();
      for (var i=0; i<rangeCount; ++i) {
         var rangeMin = {};
         var rangeMax = {};
         this._tree.view.selection.getRangeAt(i, rangeMin, rangeMax);
         for (var j=rangeMin.value; j<=rangeMax.value; ++j) {
            this._delEntryList.push(this._tree.view.getResourceAtIndex(j));
         }
      }
      if (this._delEntryList.length>0)
         this._delSelEntry();
      
   },

troypst
 
Posts: 16
Joined: March 15th, 2013, 5:19 am

Post Posted April 29th, 2014, 8:48 am

troypst wrote:Hi, I have this code...


Nevermind, I've already found the solution.

hungerburg
 
Posts: 16
Joined: September 19th, 2003, 3:23 am

Post Posted May 2nd, 2014, 5:22 am

dorando wrote:
hungerburg wrote:Can I use the keyconfig addon to make "Ctrl-Shift-F" preselect "body" in the initial term (instead of subject)?
Try to Add a new key containing:
Code: Select all
openDialog("chrome://messenger/content/SearchDialog.xul", "_blank", "chrome,resizable,status,centerscreen,dialog=no",
          { folder: gFolderDisplay.displayedFolder })
.
addEventListener("pageshow", function tempFunction(event){
 this.removeEventListener(event.type, tempFunction, false);
 var searchAttr0 = this.document.getElementById("searchAttr0");
 searchAttr0.value = searchAttr0.valueIds[searchAttr0.valueStrings.indexOf("Body")];
 this.document.getAnonymousElementByAttribute(this.document.getElementById("searchVal0"), "class", "search-value-textbox").focus();
},
 false); 



Dorando, it works! I had to replace "Body" with the localized string "Inhalt". Now I feel indebted to you…

Patu
 
Posts: 31
Joined: September 24th, 2008, 2:20 am

Post Posted May 3rd, 2014, 3:30 am

This has probably been asked before:
How do I make a button command a key command?

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

Post Posted May 13th, 2014, 5:09 am

Cattleya wrote:Example I want to delete "http://example.com/javascript/time.js" from FIrefox cache.
Try
Code: Select all
var session Services.cache.createSession("HTTP"Components.interfaces.nsICache.STORE_ANYWHEREtrue)
session.doomEntry("http://example.com/javascript/time.js"null); 

Patu wrote:How do I make a button command a key command?
You can use
Code: Select all
function getCommand(event) {
 
window.removeEventListener("command"getCommandtrue);
 
event.preventDefault();
 
event.stopPropagation();

 
alert(
  
event.originalTarget.getAttribute("oncommand") ||
  
event.originalTarget.getAttribute("onclick") ||
  
'document.getElementById("'+event.originalTarget.id+'").doCommand();');
}

window.addEventListener("command"getCommandtrue); 
to get the code of various UI elements.
Support mozilla.dorando.at through donations/contributions.

Patu
 
Posts: 31
Joined: September 24th, 2008, 2:20 am

Post Posted May 13th, 2014, 11:37 am

dorando wrote:
Patu wrote:How do I make a button command a key command?
You can use
Code: Select all
function getCommand(event) {
 window.removeEventListener("command", getCommand, true);
 event.preventDefault();
 event.stopPropagation();

 alert(
  event.originalTarget.getAttribute("oncommand") ||
  event.originalTarget.getAttribute("onclick") ||
  'document.getElementById("'+event.originalTarget.id+'").doCommand();');
}

window.addEventListener("command", getCommand, true); 
to get the code of various UI elements.

First of all thanks. But I'm a bit confused about the code. How do I apply it?

bege
 
Posts: 115
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted May 14th, 2014, 8:53 am

How can I reset a selected item in about:config with a keyconfig key?

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

Post Posted May 14th, 2014, 3:54 pm

Patu wrote:First of all thanks. But I'm a bit confused about the code. How do I apply it?
Add a new key with that code, assign a combination, press that combination in the main windows, click on an UI element.

bege wrote:How can I reset a selected item in about:config with a keyconfig key?
Try
Code: Select all
if(content.location == "about:config");
 
content.ResetSelected(); 
Support mozilla.dorando.at through donations/contributions.

Patu
 
Posts: 31
Joined: September 24th, 2008, 2:20 am

Post Posted May 15th, 2014, 12:53 am

dorando wrote:
Patu wrote:How do I apply it?
Add a new key with that code, assign a combination, press that combination in the main windows, click on an UI element.

Thanks Dorando. I had thought so but I hadn't got any response by the website applying your code. It seems that www.dict.cc disables most of my key shortcuts, including the code you gave to me. So I ended up with the Firefox web console to check on the element, and it says:
<input type="submit" onmouseup="subm_no()" onmousedown="subm_no_md()" value="Nein" style="width:190px;background-color:#ddd" tabindex="3"></input>

As I have scant knowledge in programming is this code something I can use in keyconfig?

bege
 
Posts: 115
Joined: January 23rd, 2009, 9:14 pm
Location: Germany

Post Posted May 15th, 2014, 5:49 am

dorando wrote:
bege wrote:How can I reset a selected item in about:config with a keyconfig key?
Try
Code: Select all
if(content.location == "about:config");
 content.ResetSelected(); 

Thank you :D

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

Post Posted May 18th, 2014, 11:05 am

Patu wrote:
<input type="submit" onmouseup="subm_no()" onmousedown="subm_no_md()" value="Nein" style="width:190px;background-color:#ddd" tabindex="3"></input>
As I have scant knowledge in programming is this code something I can use in keyconfig?
Try
Code: Select all
content.wrappedJSObject.subm_no(); 
Support mozilla.dorando.at through donations/contributions.

Patu
 
Posts: 31
Joined: September 24th, 2008, 2:20 am

Post Posted May 19th, 2014, 1:25 am

Thanks Dorando. I deeply appreciate your help. Your command works great for any button.
Unfortunately it's still hampered by the particular website.

I'm using the command for a vocabulary trainer on the website http://my.dict.cc/trainer/EN-DE/?&autosound=0.
Any time the page opens the cursor jumps into an embedded field where the command you gave to me doesn't work.
It will only do its job if I click into another part of the website first.

So how could I do those two steps at once?
1. Address the correct part of the website and
2. release the button by
Code: Select all
content.wrappedJSObject. * ;  

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

Post Posted May 19th, 2014, 6:48 am

Patu wrote:Any time the page opens the cursor jumps into an embedded field where the command you gave to me doesn't work.
For me it actually will only work if the cursor is in the text field (not for single letter key); if the focus is outside, the page will prevent the shortcut (see Bug 380637 - Should web pages be able to override the browser's keyboard shortcuts?).

You could try Customizable Shortcuts (together with keyconfig) since it does its own shortcut handling (unlike keyconfg).
Support mozilla.dorando.at through donations/contributions.

Ziron5
 
Posts: 2
Joined: May 19th, 2014, 6:43 am

Post Posted May 19th, 2014, 6:48 am

Hi,

is there a list of code lines beside the examples? Because i want a shortcut to "select all" and then to "copy". I already foubd out, that it's possible to give multiple functions to one shotcut. So what do I have to write into the code-box when I create a new shortcut, to simply let it "select all" and "copy"?

Thanks for answering!

Return to Extension/Theme Releases


Who is online

Users browsing this forum: No registered users and 2 guests