Announce and Discuss the Latest Theme and Extension Releases.
Zoolcar9

Posts: 2225Joined: November 9th, 2004, 6:45 pmLocation: Jakarta, Indonesia (UTC+7)
Posted June 11th, 2013, 10:42 pm
► Cattleya wrote:I want a hotkey to subscrible current page to RSS Feed, like Menu -> Bookmark -> Subscrible to This Page did 
- Code: Select all
const TITLE = "Subscribe to this page\u2026"; const kPromptService = Services.prompt;
function selectItems(aText, aArray) { var selected = {}; var result = kPromptService.select(null, TITLE, aText, aArray.length, aArray, selected); if (result) return selected.value; return false; }
function subscribeToFeed(aFeedURL) { try { return FeedHandler.subscribeToFeed(aFeedURL); } catch(ex) {} }
var feeds = gBrowser.selectedBrowser.feeds;
if (!feeds) return kPromptService.alert(null, TITLE, "No feeds found on this page.");
if (feeds.length === 1) return subscribeToFeed(feeds[0].href);
var feedNames = []; var feedURLs = []; for (var i = 0; i < feeds.length; i++) { feedNames.push(feeds[i].title); feedURLs.push(feeds[i].href); } var index = selectItems("Select feed to subscribe:", feedNames); if (index !== undefined) return subscribeToFeed(feedURLs[index]);
Revisions: 2 | 3
Last edited by Zoolcar9 on July 19th, 2013, 9:16 am, edited 2 times in total.
rbfye14
Posts: 26Joined: April 9th, 2012, 8:23 am
Posted June 23rd, 2013, 5:01 am
I made a simple script to remotely upload images to image hosting - Code: Select all
gBrowser.loadOneTab("http://housepic.org/", null, null, null, false); gBrowser.addEventListener("load", function upl() { clp = readFromClipboard(); // Image address was saved in the clipboard content.document.getElementsByName('web_uploadfile')[0].value=clp; content.document.forms[0].submit() } , true )
It works fine, but why do I keep getting these two errors? - Code: Select all
TelemetryStopwatch: key "FX_PAGE_LOAD_MS" was already initialized resource://gre/modules/TelemetryStopwatch.jsm Line: 53
And - Code: Select all
TypeError: content.document.getElementsByName(...)[0] is undefined chrome://browser/content/browser.xul Line: 4
Zoolcar9

Posts: 2225Joined: November 9th, 2004, 6:45 pmLocation: Jakarta, Indonesia (UTC+7)
Posted June 23rd, 2013, 8:12 am
rbfye14 wrote:- Code: Select all
TelemetryStopwatch: key "FX_PAGE_LOAD_MS" was already initialized resource://gre/modules/TelemetryStopwatch.jsm Line: 53
That error came from Telemetry. Just ignore it. rbfye14 wrote:- Code: Select all
TypeError: content.document.getElementsByName(...)[0] is undefined chrome://browser/content/browser.xul Line: 4
Because you didn't remove the event listener, you'll get that error because it will search for 'web_uploadfile' everytime you open a tab. Add 'removeEventListener' in your code - Code: Select all
gBrowser.loadOneTab("http://housepic.org/", null, null, null, false); gBrowser.addEventListener("load", function upl(e) { e.currentTarget.removeEventListener(e.type, arguments.callee, true); clp = readFromClipboard(); content.document.getElementsByName('web_uploadfile')[0].value=clp; content.document.forms[0].submit() }, true)
or change your code (add event listener to browser object inside the tab instead of global browser) - Code: Select all
var tab = gBrowser.loadOneTab("http://housepic.org/", null, null, null, false); tab.linkedBrowser.addEventListener("load", function upl(e) { e.currentTarget.removeEventListener(e.type, arguments.callee, true); clp = readFromClipboard(); content.document.getElementsByName('web_uploadfile')[0].value=clp; content.document.forms[0].submit() }, true )
rbfye14
Posts: 26Joined: April 9th, 2012, 8:23 am
Posted June 24th, 2013, 2:10 am
Patu
Posts: 31Joined: September 24th, 2008, 2:20 am
Posted June 25th, 2013, 12:20 am
Hi Dorando, I remember you were considering an import/export-function for keyconfig.
Is it going to come?
dorando
Posts: 1203Joined: January 9th, 2004, 9:57 am
Posted June 29th, 2013, 11:32 am
Eventually, but likely not in the next release.
ltwally
Posts: 13Joined: November 24th, 2005, 10:16 am
Posted July 4th, 2013, 7:51 am
Anyone know if it's possible to create a shortcut for Thunderbird to start a bullet list in the new message window? If so, how?
Thanks
RegiOween

Posts: 3Joined: September 11th, 2008, 6:59 pm
Posted July 4th, 2013, 5:50 pm
Hi, folks!
I've searched this thread for some way to open Firefox context-menu at mouse position (simulating a right-button click), but didn't find nothing. I already tried many javascript, jquery and xul snippets, but nothing worked, so I ask you for some guidance to do that.
Thanks in advance.
RegiOween
morat
Posts: 4283Joined: February 3rd, 2009, 6:29 pm
Posted July 6th, 2013, 4:02 pm
@ltwally Try this: - Code: Select all
doStyleUICommand("cmd_ul");
I found the command by running the following code and clicking on the menu item. - Code: Select all
function getCommand(event) { window.removeEventListener("command", getCommand, true); event.preventDefault(); event.stopPropagation(); alert(event.target.getAttribute("oncommand") || event.target.getAttribute("onclick")); } window.addEventListener("command", getCommand, true);
This trick does not work for all user interface elements. @RegiOween Try these: - Code: Select all
var popup = document.getElementById("contentAreaContextMenu"); var anchor = gBrowser.tabs[0]; var position = "after_start"; var x = 0; var y = 0; var isContextMenu = true; var attributesOverride = true; popup.openPopup(anchor, position, x, y, isContextMenu, attributesOverride);
- Code: Select all
var popup = document.getElementById("contentAreaContextMenu"); var x = window.outerWidth / 4; var y = window.outerHeight / 4; var isContextMenu = true; popup.openPopupAtScreen(x, y, isContextMenu);
- Code: Select all
var utils = gBrowser.contentWindow. QueryInterface(Components.interfaces.nsIInterfaceRequestor). getInterface(Components.interfaces.nsIDOMWindowUtils); var x = 0; var y = 0; var button = 2; var clickCount = 1; var modifiers = 0; utils.sendMouseEvent("contextmenu", x, y, button, clickCount, modifiers);
I do not know how to get the mouse position. https://developer.mozilla.org/en/XUL/Method/openPopuphttps://developer.mozilla.org/en/XUL/Me ... upAtScreenhttps://developer.mozilla.org/en/XUL/Po ... ositioninghttps://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIDOMWindowUtils#sendMouseEvent()You can use the Shift+F10 keyboard shortcut or Menu key to launch a context menu. http://en.wikipedia.org/wiki/Menu_keyYou can use the NirCmd program to send a right click. - Code: Select all
var localFile = Components.classes["@mozilla.org/file/local;1"]. createInstance(Components.interfaces.nsILocalFile); var process = Components.classes["@mozilla.org/process/util;1"]. createInstance(Components.interfaces.nsIProcess); var args = ["sendmouse", "right", "click"]; localFile.initWithPath("C:\\nircmd.exe"); process.init(localFile); process.run(false, args, args.length); http://www.nirsoft.net/utils/nircmd.htmlhttp://www.nirsoft.net/utils/nircmd2.html#sendmouse
Last edited by morat on July 14th, 2013, 11:18 am, edited 2 times in total.
GotA20
Posts: 2Joined: July 11th, 2013, 2:27 pm
Posted July 11th, 2013, 2:36 pm
Is there a way to close all private browsing windows using keyconfig?
Thanks in advance!
Zoolcar9

Posts: 2225Joined: November 9th, 2004, 6:45 pmLocation: Jakarta, Indonesia (UTC+7)
Posted July 12th, 2013, 11:28 am
GotA20 wrote:Is there a way to close all private browsing windows using keyconfig?
- Code: Select all
var em = Services.wm.getEnumerator("navigator:browser"); var win; while (em.hasMoreElements()) { win = em.getNext(); if (PrivateBrowsingUtils.isWindowPrivate(win)) win.close(); }
s.p. If you only want to use only ONE private window, install Open in Private Window extension or Private Tab.
nigelle
Posts: 117Joined: June 9th, 2005, 8:30 amLocation: France
Posted July 13th, 2013, 4:31 am
To Patu My private copy of Keyconfig has import/export. In the past, Dorando has given the (long) codes to define a) import (from a file), b) export (to a file) short-cuts. This is not very convenient because if you wish to import your old short-cuts to a new FF profile, you have first to download Keyconfig then define the import short-cut then use it. This process consumes 2 letter-combinations to define the 2 short-cuts that are not frequently used.
I see an other solution for Dorando : -He integrate in the next release the short-cut to execute the code placed in the clipboard (this code has been given in the past). This short-cut may have many other applications. -He put as downloadable files (for us) in his site the codes to put in clipboard for a) export, b) import, c) printing the list of short-cuts (that was also contributed at nearly the same time), any other utilities (to be defined) for keyconfig...
dorando
Posts: 1203Joined: January 9th, 2004, 9:57 am
Posted July 14th, 2013, 11:30 am
RegiOween wrote:I've searched this thread for some way to open Firefox context-menu at mouse position (simulating a right-button click), but didn't find nothing.
I am not aware of any internal API for getting the mouse position (outside a mouse event), but try (only works on Windows) - Code: Select all
Components.utils.import("resource://gre/modules/ctypes.jsm"); var user32 = ctypes.open("user32");
var BOOL = ctypes.int; var LONG = ctypes.long;
var POINT = ctypes.StructType("tagPOINT", [ { x : LONG }, { y : LONG } ]);
var LPPOINT = POINT.ptr;
var GetCursorPos = user32.declare('GetCursorPos', ctypes.winapi_abi, BOOL, LPPOINT);
var point = new POINT; if(GetCursorPos(point.address())) { var utils = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor). getInterface(Components.interfaces.nsIDOMWindowUtils);
var MOUSEEVENTF_RIGHTDOWN = 0x0008; var MOUSEEVENTF_RIGHTUP = 0x0010; utils.sendNativeMouseEvent(point.x, point.y, MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, null); }
user32.close();
morat
Posts: 4283Joined: February 3rd, 2009, 6:29 pm
Posted July 15th, 2013, 6:06 am
@dorando Nicely done. The cursor moves in the ctypes example when I hold down the shortcut keys. I got the ctypes example to work like the NirCmd example with the following tweak. - Code: Select all
var x = point.x - window.screenX; var y = point.y - window.screenY; utils.sendNativeMouseEvent(x, y, MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, null);
Cattleya
Posts: 57Joined: October 7th, 2010, 11:14 pm
Posted July 19th, 2013, 2:57 am
Zoolcar9 wrote:► Cattleya wrote:I want a hotkey to subscrible current page to RSS Feed, like Menu -> Bookmark -> Subscrible to This Page did 
- Code: Select all
const TITLE = "Subscribe to this page\u2026"; const kPromptService = Services.prompt;
function selectItems(aText, aArray) { var selected = {}; var result = kPromptService.select(null, TITLE, aText, aArray.length, aArray, selected); if (result) return selected.value; return; }
var feeds = content.document.querySelectorAll('link[rel="alternate"]\[type^="application/"]\[type$="+xml"]'); if (!feeds.length) { kPromptService.alert(null, TITLE, "No feeds found on this page."); return; }
if (feeds.length === 1) { FeedHandler.subscribeToFeed(feeds[0].href); return; }
var feedNames = []; var feedURLs = []; for (var i = 0; i < feeds.length; i++) { feedNames.push(feeds[i].title); feedURLs.push(feeds[i].href); } var index = selectItems("Select feed to subscribe:", feedNames); if (index !== undefined) FeedHandler.subscribeToFeed(feedURLs[index]);
Many thank, Zoolcar, you helped me so much 
Return to Extension/Theme Releases
Who is online
Users browsing this forum: No registered users and 2 guests
|