Home > Blockchain >  how to access browser %variables% (enclosed in percent % signs)
how to access browser %variables% (enclosed in percent % signs)

Time:12-23

In various browsers you can find these type of variables %VAR%

In firefox about:config you can find:

%LOCALE%
%VERSION%
%OS%
%GOOGLE_LOCATION_SERVICE_API_KEY%

etc..

Where are those variables stored or set, and how to console log their value?

CodePudding user response:

console.log(navigator) will give you information that the browser has

CodePudding user response:

in firefox source code file named URLFormatter.jsm, you can see how those variables are declared.

For example, %OS% return a value from Services.appinfo.OS

%LOCALE% returns Services.locale.appLocaleAsBCP47

%CHANNEL% returns UpdateUtils.UpdateChannel

%GOOGLE_LOCATION_SERVICE_API_KEY% returns AppConstants.MOZ_GOOGLE_LOCATION_SERVICE_API_KEY

Those functions are defined within the prototype nsURLFormatterService but to access AppConstants for example, you need to use a custom firefox build,; like Firefox Nightly or enable experimental mode.

Those variables can be imported within a custom addon, and importing them using ChromeUtils.

const { AppConstants } = ChromeUtils.import(
  "resource://gre/modules/AppConstants.jsm"
);

Here is the more advanced documentation

  • Related