From 4b1a9203c547c019fc5398082ae19a3f3d4c3efe Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:15 -0500 Subject: initial commit --- .../webextensions/api/browsingdata/index.html | 122 +++++++++++++++++++++ .../webextensions/api/contentscripts/index.html | 38 +++++++ .../mozilla/add-ons/webextensions/api/index.html | 53 +++++++++ 3 files changed, 213 insertions(+) create mode 100644 files/ar/mozilla/add-ons/webextensions/api/browsingdata/index.html create mode 100644 files/ar/mozilla/add-ons/webextensions/api/contentscripts/index.html create mode 100644 files/ar/mozilla/add-ons/webextensions/api/index.html (limited to 'files/ar/mozilla/add-ons/webextensions/api') diff --git a/files/ar/mozilla/add-ons/webextensions/api/browsingdata/index.html b/files/ar/mozilla/add-ons/webextensions/api/browsingdata/index.html new file mode 100644 index 0000000000..2ef0a4433f --- /dev/null +++ b/files/ar/mozilla/add-ons/webextensions/api/browsingdata/index.html @@ -0,0 +1,122 @@ +--- +title: browsingData +slug: Mozilla/Add-ons/WebExtensions/API/browsingData +translation_of: Mozilla/Add-ons/WebExtensions/API/browsingData +--- +

+ +

{{AddonSidebar}}

+ +

Enables extensions to clear the data that is accumulated while the user is browsing.

+ +

In the browsingData API, browsing data is divided into types:

+ + + +

You can use the {{WebExtAPIRef("browsingData.remove()")}} function to remove any combination of these types. There are also dedicated functions to remove each particular type of data, such as {{WebExtAPIRef("browsingData.removePasswords()", "removePasswords()")}}, {{WebExtAPIRef("browsingData.removeHistory()", "removeHistory()")}} and so on.

+ +

All the browsingData.remove[X]() functions take a {{WebExtAPIRef("browsingData.RemovalOptions")}} object, which you can use to control two further aspects of data removal:

+ + + +

Finally, this API gives you a {{WebExtAPIRef("browsingData.settings()")}} function that gives you the current value of the settings for the browser's built-in "Clear History" feature.

+ +

To use this API you must have the "browsingData" API permission.

+ +

Types

+ +
+
{{WebExtAPIRef("browsingData.DataTypeSet")}}
+
Object used to specify the type of data to remove: for example, history, downloads, passwords, and so on.
+
{{WebExtAPIRef("browsingData.RemovalOptions")}}
+
Object used to specify how far back in time to remove data, and whether to remove data added through normal web browsing, by hosted apps, or by add-ons.
+
+ +

Methods

+ +
+
{{WebExtAPIRef("browsingData.remove()")}}
+
Removes browsing data for the data types specified.
+
{{WebExtAPIRef("browsingData.removeCache()")}}
+
Clears the browser's cache.
+
{{WebExtAPIRef("browsingData.removeCookies()")}}
+
Removes cookies.
+
{{WebExtAPIRef("browsingData.removeDownloads()")}}
+
Removes the list of downloaded files.
+
{{WebExtAPIRef("browsingData.removeFormData()")}}
+
Clears saved form data.
+
{{WebExtAPIRef("browsingData.removeHistory()")}}
+
Clears the browser's history.
+
{{WebExtAPIRef("browsingData.removeLocalStorage()")}}
+
Clears any local storage created by websites.
+
{{WebExtAPIRef("browsingData.removePasswords()")}}
+
Clears saved passwords.
+
{{WebExtAPIRef("browsingData.removePluginData()")}}
+
Clears data associated with plugins.
+
{{WebExtAPIRef("browsingData.settings()")}}
+
Gets the current value of settings in the browser's "Clear History" feature.
+
+ +

Browser compatibility

+ + + +

{{Compat("webextensions.api.browsingData", 2)}}

+ + + +

{{WebExtExamples("h2")}}

+ +
Acknowledgements + +

This API is based on Chromium's chrome.browsingData API.

+ +

Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.

+
+ + diff --git a/files/ar/mozilla/add-ons/webextensions/api/contentscripts/index.html b/files/ar/mozilla/add-ons/webextensions/api/contentscripts/index.html new file mode 100644 index 0000000000..16f7fa2fdf --- /dev/null +++ b/files/ar/mozilla/add-ons/webextensions/api/contentscripts/index.html @@ -0,0 +1,38 @@ +--- +title: contentScripts +slug: Mozilla/Add-ons/WebExtensions/API/contentScripts +translation_of: Mozilla/Add-ons/WebExtensions/API/contentScripts +--- +
{{AddonSidebar}}
+ +

Use this API to register content scripts. Registering a content script instructs the browser to insert the given content scripts into pages that match the given URL patterns.

+ +

This API is very similar to the "content_scripts" manifest.json key, except that with  "content_scripts" , the set of content scripts and associated patterns is fixed at install time. With the contentScripts API, an extension can register and unregister scripts at runtime.

+ +

To use the API, call {{WebExtAPIRef("contentScripts.register()")}} passing in an object defining the scripts to register, the URL patterns, and other options. This returns a Promise that is resolved with a {{WebExtAPIRef("contentScripts.RegisteredContentScript")}} object.

+ +

The RegisteredContentScript object represents the scripts that were registered in the register() call. It defines an unregister() method that you can use to unregister the content scripts. Content scripts are also unregistered automatically when the page that created them is destroyed. For example, if they are registered from the background page they will be unregistered automatically when the background page is destroyed, and if they are registered from a sidebar or a popup, they will be unregistered automatically when the sidebar or popup is closed.

+ +

There is no contentScripts API permission, but an extension must have the appropriate host permissions for any patterns it passes to register().

+ +

Types

+ +
+
{{WebExtAPIRef("contentScripts.RegisteredContentScript")}}
+
+

An object of this type is returned by the {{WebExtAPIRef("contentScripts.register()")}} function. It represents the content scripts that were registered by that call, and can be used to unregister the content script.

+
+
+ +

Functions

+ +
+
{{WebExtAPIRef("contentScripts.register()")}}
+
Registers the given content scripts.
+
+ +

Browser compatibility

+ +

{{Compat("webextensions.api.contentScripts", 10, 1)}}

+ +

 {{WebExtExamples("h2")}}

diff --git a/files/ar/mozilla/add-ons/webextensions/api/index.html b/files/ar/mozilla/add-ons/webextensions/api/index.html new file mode 100644 index 0000000000..955086de10 --- /dev/null +++ b/files/ar/mozilla/add-ons/webextensions/api/index.html @@ -0,0 +1,53 @@ +--- +title: JavaScript APIs +slug: Mozilla/Add-ons/WebExtensions/API +tags: + - NeedsTranslation + - TopicStub + - WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/API +--- +
{{AddonSidebar}}
+ +
+

JavaScript APIs for WebExtensions can be used inside the extension's background scripts and in any other documents bundled with the extension, including browser action or page action popups, sidebars, options pages, or new tab pages. A few of these APIs can also be accessed by an extension's content scripts (see the list in the content script guide).

+ +

To use the more powerful APIs you need to request permission in your extension's manifest.json.

+ +

You can access the APIs using the browser namespace:

+ +
function logTabs(tabs) {
+  console.log(tabs);
+}
+
+browser.tabs.query({currentWindow: true}, logTabs);
+
+ +
+

Many of the APIs are asynchronous, returning a Promise:

+ +
function logCookie(c) {
+  console.log(c);
+}
+
+function logError(e) {
+  console.error(e);
+}
+
+var setCookie = browser.cookies.set(
+  {url: "https://developer.mozilla.org/"}
+);
+setCookie.then(logCookie, logError);
+
+ +
+

Note that this is different from Google Chrome's extension system, which uses the chrome namespace instead of browser, and which uses callbacks instead of promises for asynchronous functions. As a porting aid, the Firefox implementation of WebExtensions APIs supports chrome and callbacks as well as browser and promises. Mozilla has also written a polyfill which enables code that uses browser and promises to work unchanged in Chrome: https://github.com/mozilla/webextension-polyfill.

+ +

Firefox also implements these APIs under the chrome namespace using callbacks. This allows code written for Chrome to run largely unchanged in Firefox for the APIs documented here.

+ +

Microsoft Edge uses the browser namespace, but doesn't yet support promise-based asynchronous APIs. In Edge, for the time being, asynchronous APIs must use callbacks.

+ +

Not all browsers support all the APIs: for the details, see Browser support for JavaScript APIs.

+
+ +
{{SubpagesWithSummaries}}
-- cgit v1.2.3-54-g00ecf