Building on Rob Kennedy's answer and using NDde
Copyusing NDde.Client;
class Test
{
public static string GetFirefoxURL()
{
DdeClient dde = new DdeClient("Firefox", "WWW_GetWindowInfo");
dde.Connect();
string url = dde.Request("URL", int.MaxValue);
dde.Disconnect();
return url;
}
}
NB: This is very slow. It takes a few seconds on my computer. The result will look something like this :
Copy"http://stackoverflow.com/questions/430614/get-firefox-url","Get Firefox URL? - Stack Overflow",""
More info on browser DDE here.
Answer from Foole on Stack OverflowWhat URLs are used to update the browser
c# - Get Firefox URL? - Stack Overflow
Getting current browser url in Firefox Addon
How do I bring back the full URL in the address bar? I want to see https://www.example.com
Videos
So I have a couple of computers that shouldn't get 100% internet access but SOME things can be allowed that are essential, like browser updates.
Google Chrome currently works without any problems and they have their URLs listed.
However, FF only has, to my knowledge, one: aus5.mozilla.org
but updating fails, even with the use of wildcards.
Allowing www.mozilla.org and ftp.mozilla.org also doesn't work.
So far with those URLs it can detect that a new version is available and starts downloading with zero progress. ftp.mozilla.org at least allows me to manually download an installer but it would be nice to get auto updates working.
VeryLateUpdate:
I got this working by allowing the following FQDNs:
aus5.mozilla.org
download.mozilla.org
ftp.mozilla.org
www.mozilla.org
For some reason if I use FQDN objects it works but using CheckPoint's "Custom Application Site" object
it doesn't work (well it does but something is making it fail).
Haven't taken a deep look into why this was the case but at least it's been working for
several months.
Building on Rob Kennedy's answer and using NDde
Copyusing NDde.Client;
class Test
{
public static string GetFirefoxURL()
{
DdeClient dde = new DdeClient("Firefox", "WWW_GetWindowInfo");
dde.Connect();
string url = dde.Request("URL", int.MaxValue);
dde.Disconnect();
return url;
}
}
NB: This is very slow. It takes a few seconds on my computer. The result will look something like this :
Copy"http://stackoverflow.com/questions/430614/get-firefox-url","Get Firefox URL? - Stack Overflow",""
More info on browser DDE here.
For most browsers, including Internet Explorer, Navigator, Firefox, and Opera, the supported and sanctioned way of doing this is to use DDE. The topic name in all of them is WWW_GetWindowInfo; only the name of the target window varies. That technique will be difficult for you, though, because .Net doesn't support DDE. If you can find a way to get around that limitation, you'll be all set.
getting the URL from a sidebar or popup
To retrieve the URL from a sidebar or popup requires tab permissions
"permissions": [
"tabs"
]
then you need to find the tab you want. If you just want the active tab this would work fine, for anything more advanced I'd look here.
function getPage(){
browser.tabs.query({currentWindow: true, active: true})
.then((tabs) => {
console.log(tabs[0].url);
})
}
getting the URL from injected javascript
If you want the URL for a background task I suggest this method as you do not need permissions.
this will give you a background script and then inject a script onto almost any webpage on the internet.
"background": {
"scripts": ["background.js"]
},
"content_scripts": [
{
"matches": ["https://www.*"],
"js": ["modify-page/URL.js"]
}
],
this will be injected into webpages through the URL js and will send a message to your background js to use.
var service= browser.runtime.connect({name:"port-from-cs"});
service.postMessage({location: document.URL});
This code is in your background js and will collect each new page's url as it changes.
var portFromCS;
function connected(p) {
portFromCS = p;
portFromCS.onMessage.addListener(function(m) {
if(m.location !== undefined){
console.log(m.location);
}
});
}
browser.runtime.onConnect.addListener(connected);
// you need to use this service first
var windowsService = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService(Components.interfaces.nsIWindowMediator);
// window object representing the most recent (active) instance of Firefox
var currentWindow = windowsService.getMostRecentWindow('navigator:browser');
// most recent (active) browser object - that's the document frame inside the chrome
var browser = currentWindow.getBrowser();
// object containing all the data about an address displayed in the browser
var uri = browser.currentURI;
// textual representation of the actual full URL displayed in the browser
var url = uri.spec;
You can do it like:
firefox -new-tab "https://www.useotools.com"
OR with full path
"C:\Program Files\Mozilla Firefox\firefox.exe" -new-tab "https://www.useotools.com"
Well at least one possible method is to modify your about:config files. See http://www.ghacks.net/2009/07/03/force-firefox-to-open-links-in-same-tab/ for details as to how to do this.
I want to see https://www.example.com instead of just www.example.com without having to click the address bar.