diff options
Diffstat (limited to 'files/ar/mozilla/add-ons')
13 files changed, 1476 insertions, 0 deletions
diff --git a/files/ar/mozilla/add-ons/add-on_guidelines/index.html b/files/ar/mozilla/add-ons/add-on_guidelines/index.html new file mode 100644 index 0000000000..a2ceecab7b --- /dev/null +++ b/files/ar/mozilla/add-ons/add-on_guidelines/index.html @@ -0,0 +1,116 @@ +--- +title: Add-on guidelines +slug: Mozilla/Add-ons/Add-on_guidelines +translation_of: 'https://extensionworkshop.com/documentation/publish/add-on-policies/' +--- +<p>These add-on guidelines were created to foster an open and diverse add-on developer community while ensuring an excellent user experience. They apply to all add-ons and add-on updates regardless of where they are hosted, and also apply to customizations performed by installers that configure Firefox without using an add-on. Add-ons hosted on <a class="external text" href="https://addons.mozilla.org/" rel="nofollow">AMO</a> are subject to <a href="https://addons.mozilla.org/developers/docs/policies" title="https://addons.mozilla.org/developers/docs/policies">additional policies</a>.</p> +<h2 id="Be_Transparent">Be Transparent</h2> +<ul> + <li>Add-ons must either be installed using the add-on web install system, or be approved by the user using the <a class="external text" href="https://blog.mozilla.org/addons/2011/08/11/strengthening-user-control-of-add-ons/" rel="nofollow">install opt-in dialog</a>. + <ul> + <li>We want our users to know what they are installing so that they are not unpleasantly surprised by changes they did not expect. We also want them to know what to remove if they decide not to keep it.</li> + <li>Add-ons installed through application installers should <a class="external text" href="/en-US/docs/Adding_Extensions_using_the_Windows_Registry" rel="nofollow">use the Windows Registry</a> or equivalent global install methods so that Firefox displays the opt-in screen. The opt-in screen must not be tampered with in any way, including overlaying additional information or images on top of it.</li> + </ul> + </li> + <li>Add-ons must always be possible to uninstall or disable from the Add-ons Manager. + <ul> + <li>Add-ons installed globally using the Windows registry or global extension directories cannot be uninstalled (<a class="external text" href="https://bugzilla.mozilla.org/show_bug.cgi?id=640775" rel="nofollow">bug 640775</a>), but they can be disabled to the same effect.</li> + </ul> + </li> + <li>Add-ons must use a <a class="external text" href="/en-US/docs/Install_manifests#id" rel="nofollow">single unique ID</a> during their entire lifetime. + <ul> + <li>Using the same ID for multiple products, or multiple IDs for a single product, can lead to problems with automatic updates as well as blocklisting conflicts. Add-ons may change their IDs due to ownership changes, as they commonly use an email address-like format ( + <i> + e.g.,</i> + personasplus@mozilla.com).</li> + </ul> + </li> + <li>Add-ons must not use brand names, trademarks, or other terms in ways that deceive users. Using Mozilla trademarks must follow <a class="external text" href="http://www.mozilla.org/foundation/trademarks/policy.html" rel="nofollow">our trademark policy</a>.</li> + <li>Add-ons should clearly communicate their intended purpose and active features, including features introduced through updates. + <ul> + <li>While we understand and support add-on developers who choose to monetize their products, this should not come at the expense of users' browsing experience. If an add-on inserts advertisements, affiliate codes, sponsored search results, or the like, into web pages, the user should be made aware of this when the add-on is installed. Likewise, if some features require payment to use, or require payment to remain active after a trial period, users should be made aware of this.</li> + </ul> + </li> +</ul> +<h2 id="Be_Respectful_to_Users">Be Respectful to Users</h2> +<ul> + <li>Add-ons must remove all introduced code, executables, and application configuration changes when they are uninstalled. + <ul> + <li>Uninstalling an add-on using the regular uninstall process should generally suffice. This guideline primarily applies to changes made to preferences such as the homepage, default search URL, network settings, and so forth. These preferences should be restored to their previous values when the add-on is uninstalled. Most add-ons can easily accomplish this by making such changes via a <a class="external text" href="/en-US/docs/Building_an_Extension#Defaults_Files" rel="nofollow">default preferences file</a>.</li> + </ul> + </li> + <li>Add-ons should respect the users' choices and not make unexpected changes, or limit users' ability to revert them. + <ul> + <li>For instance, users generally do not expect an add-on to change the Firefox homepage. Asking users to opt-in to such extra changes is recommended. Making them difficult or impossible to revert is strongly discouraged.</li> + </ul> + </li> + <li>Add-ons should make it clear how private user data is being used. + <ul> + <li>Add-ons which send user data over the Internet should generally provide a Privacy Policy, ideally concise and easily readable.</li> + </ul> + </li> + <li>Add-on developers should provide a mechanism for them to be contacted. + <ul> + <li>While developers are not required to provide a support channel for users, it is recommended. All add-on developers should have a contact form or public email address so that they can be contacted in case of emergencies, such as guideline violations that could lead to blocklisting.</li> + </ul> + </li> +</ul> +<h2 id="Be_Safe">Be Safe</h2> +<ul> + <li>Add-ons must not cause harm to users' data, system, or online identities.</li> + <li>Add-ons must not transmit users' private data unsafely, or expose it to third parties unnecessarily. + <ul> + <li>Private data should always be sent over a secure connection. This includes browsing data such as visited URLs and bookmarks.</li> + <li>Making the browser easier to fingerprint by adding text to the User-Agent string or adding custom headers is also a privacy concern, and should be avoided.</li> + </ul> + </li> + <li>Add-ons must not create or expose application or system vulnerabilities. + <ul> + <li>Security bugs happen, but once discovered they need to be addressed immediately. A popular add-on with a security vulnerability is a valuable attack vector for hackers, and in such cases we will move quickly to blocklist the add-on if there is no prompt response from the developer.</li> + </ul> + </li> + <li>Add-ons must not tamper with the application or blocklist update systems.</li> + <li>Add-ons should not store any browsing data while in Private Browsing Mode. + <ul> + <li>It's worth stressing that PBM is about avoiding storing + <i> + local</i> + data while browsing, not about sending data elsewhere. To learn more about PBM we recommend reading <a class="external text" href="http://ehsanakhgari.org/tag/privatebrowsing" rel="nofollow">Ehsan's blog posts</a> about it.</li> + </ul> + </li> +</ul> +<h2 id="Be_Stable">Be Stable</h2> +<ul> + <li>Add-ons must not cause hangs or crashes.</li> + <li>Add-ons should not break or disable core application features. + <ul> + <li>This includes features like tabbed browsing, Private Browsing Mode, and the location bar. Add-ons that are specifically meant to do this are exempt.</li> + </ul> + </li> + <li>Add-ons should not cause memory leaks, or unnecessarily consume large amounts of memory.</li> + <li>Add-ons should not slow down the application or system significantly.</li> + <li>Add-ons should not consume network resources to an extent that affects regular application usage. + <ul> + <li>Downloading large amounts of data without user awareness can significantly disrupt regular browsing, and may result in unexpected charges for users who have network usage limitations (notably on mobile).</li> + </ul> + </li> +</ul> +<h2 id="Exceptions">Exceptions</h2> +<ul> + <li>Add-ons can break some of these guidelines if that's their intended purpose and there isn't malicious intent ( + <i> + e.g.,</i> + a security exploit proof of concept).</li> + <li>Add-ons deployed by administrators within workplaces, schools, kiosks, and so forth, are exempt from most guidelines.</li> + <li>As add-ons can only run clean up code if they are uninstalled while Firefox is running and they are enabled, we do not require that they attempt to clean up after themselves when they are uninstalled under other circumstances. Application installers that configure Firefox without add-ons should revert any changes when uninstalled.</li> + <li>Add-ons may leave behind preferences changes in private preference branches which do not affect Firefox when the add-on is not active, so that any previous add-on configuration is not lost if the user decides to re-install the add-on in the future.</li> +</ul> +<p>Other exceptions may apply.</p> +<h2 id="Enforcement">Enforcement</h2> +<p>Add-ons that do not follow these guidelines may qualify for blocklisting, depending on the extent of the violations. Guidelines qualified with the word + <i> + must</i> + are especially important, and violations thereof will most likely result in a blocklisting nomination.</p> +<p>The Add-ons Team will do their best to contact the add-on's developers and provide a reasonable time frame for the problems to be corrected before a block is put in place. If an add-on is considered malicious or its developers have proven unreachable or unresponsive, or in case of repeat violations, blocklisting may be immediate.</p> +<p>Guideline violations should be <a class="external text" href="https://bugzilla.mozilla.org/enter_bug.cgi?product=Tech%20Evangelism&component=Add-ons" rel="nofollow">reported via Bugzilla</a>, under Tech Evangelism > Add-ons. Questions can be posted in the <a class="external text" href="irc://irc.mozilla.org/addons" rel="nofollow">#addons IRC channel</a>.</p> +<p>These guidelines may change in the future. All updates will be announced in the <a class="external text" href="https://blog.mozilla.org/addons/" rel="nofollow">Add-ons Blog</a>.</p> diff --git a/files/ar/mozilla/add-ons/amo/index.html b/files/ar/mozilla/add-ons/amo/index.html new file mode 100644 index 0000000000..e1684b2100 --- /dev/null +++ b/files/ar/mozilla/add-ons/amo/index.html @@ -0,0 +1,15 @@ +--- +title: AMO +slug: Mozilla/Add-ons/AMO +tags: + - NeedsTranslation + - TopicStub +translation_of: Mozilla/Add-ons/AMO +--- +<p>Pages documenting <a href="https://addons.mozilla.org/en-US/firefox/">addons.mozilla.org</a>:</p> + +<p>{{Listsubpages("/en-US/Add-ons/AMO", 10)}}</p> + +<p> </p> + +<p> </p> diff --git a/files/ar/mozilla/add-ons/amo/policy/index.html b/files/ar/mozilla/add-ons/amo/policy/index.html new file mode 100644 index 0000000000..669d7f8f2d --- /dev/null +++ b/files/ar/mozilla/add-ons/amo/policy/index.html @@ -0,0 +1,21 @@ +--- +title: AMO Policies +slug: Mozilla/Add-ons/AMO/Policy +tags: + - NeedsTranslation + - TopicStub +translation_of: Mozilla/Add-ons/AMO/Policy +--- +<p>{{AddonSidebar}}</p> + +<p>Mozilla is committed to ensuring an excellent experience for both our users and developers of add-ons. Please review the policies below before submitting your add-on.</p> + +<dl> + <dd></dd><dt><a href="/Mozilla/Add-ons/AMO/Policy/Agreement">Developer Agreement</a></dt> +<dd>Effective January 5, 2016</dd> <dt><a href="/Mozilla/Add-ons/AMO/Policy/Reviews">Review Process</a></dt> +<dd>Add-ons extend the core capabilities of Firefox, allowing users to modify and personalize their Web experience. A healthy add-on ecosystem, built on trust, is vital for developers to be successful and users to feel safe making Firefox their own. For these reasons, Mozilla requires all add-ons to comply with the following set of policies on acceptable practices. The below is not intended to serve as legal advice, nor is it intended to serve as a comprehensive list of terms to include in your add-on’s privacy policy.</dd> <dt><a href="/Mozilla/Add-ons/AMO/Policy/Featured">Featured Add-ons</a></dt> +<dd>How up-and-coming add-ons become featured and what's involved in the process. </dd> <strong><a href="/en-US/Add-ons#Contact_us">Contacting us</a></strong> + + <p> How to get in touch with us regarding these policies or your add-on.</p> + +</dl> diff --git a/files/ar/mozilla/add-ons/index.html b/files/ar/mozilla/add-ons/index.html new file mode 100644 index 0000000000..3e0a66abdb --- /dev/null +++ b/files/ar/mozilla/add-ons/index.html @@ -0,0 +1,92 @@ +--- +title: Add-ons +slug: Mozilla/Add-ons +tags: + - Add-ons + - NeedsTranslation + - TopicStub +translation_of: Mozilla/Add-ons +--- +<div class="summary"><font><font>تعديل وتوسيع تطبيقات موزيلا</font></font></div> + +<p><span class="seoSummary"><font><font>تضيف الإضافات وظائف جديدة إلى </font><font>تطبيقات </font></font><a href="/en-US/docs/Mozilla/Gecko"><font><font>Gecko-</font></font></a><font><font> based مثل Firefox و SeaMonkey و Thunderbird. </font></font></span><strong> </strong><font><font>هناك نوعان رئيسيان من الوظائف الإضافية: </font></font><a href="#Extensions"><font><font>الإضافات</font></font></a><font><font> تضيف ميزات جديدة إلى التطبيق ، بينما تقوم </font></font><a href="#Themes"><font><font>السمات</font></font></a><font><font> بتعديل واجهة المستخدم الخاصة بالتطبيق.</font></font></p> + +<p><font><font>بالنسبة إلى كل من الإضافات والمظاهر ، تشغل Mozilla مستودعًا في </font></font><a href="https://addons.mozilla.org/"><font><font>addons.mozilla.org</font></font></a><font><font> ، والمعروف أيضًا باسم AMO. </font><font>عند </font></font><a href="/en-US/Add-ons/Submitting_an_add-on_to_AMO"><font><font>إرسال إضافات إلى AMO</font></font></a><font><font> يتم مراجعتها ، وبعد اجتياز المراجعة يتم إتاحتها للمستخدمين. </font><font>لا يتعين عليك تقديم إضافات إلى AMO ، ولكن إذا قمت بذلك ، يمكن للمستخدمين الوثوق في حقيقة أنهم قد تمت مراجعتهم ، ويمكنك الاستفادة من رؤية AMO كمصدر للوظائف الإضافية المفيدة.</font></font></p> + +<p><font><font>يمكن أن تؤثر الإضافات بشكل كبير على سلوك التطبيق الذي يستضيفها. </font><font>لقد طورنا </font></font><a href="/en-US/docs/Mozilla/Add-ons/Add-on_guidelines"><font><font>مجموعة من الإرشادات</font></font></a><font><font> للمساعدة في ضمان تقديم تجربة جيدة للمستخدمين. </font><font>تنطبق هذه الإرشادات على جميع أنواع الإضافات ، سواء تم استضافتها على </font></font><a href="https://addons.mozilla.org/"><font><font>addons.mozilla.org</font></font></a><font><font> أم لا.</font></font></p> + +<hr> +<h2 id="ملحقات"><a name="Extensions"><font><font>ملحقات</font></font></a></h2> + +<p><font><font>تضيف الإضافات وظائف جديدة إلى تطبيقات Mozilla مثل Firefox و Thunderbird. </font><font>يمكنهم إضافة ميزات جديدة إلى المتصفح ، مثل طريقة مختلفة لإدارة علامات التبويب ، ويمكنهم تعديل محتوى الويب لتحسين إمكانية الاستخدام أو الأمان لمواقع ويب معينة.</font></font></p> + +<p><font><font>هناك ثلاثة أساليب مختلفة يمكنك استخدامها لإنشاء إضافات: الإضافات المستندة إلى SDK الإضافي ، وإضافات غير قابلة لإعادة التشغيل يدويًا ، وإضافات التراكب.</font></font></p> + +<ul class="card-grid"> + <li><span><a href="https://developer.mozilla.org/en-US/Add-ons/SDK"><font><font>ملحقات SDK للإضافة قم</font></font></a></span><br> + <font><font>بتطوير</font><span><a href="https://developer.mozilla.org/en-US/Add-ons/SDK"><font> إضافات</font></a></span><font> إعادة التشغيل باستخدام مجموعة من واجهات برمجة تطبيقات جافا سكريبت عالية المستوى.</font></font></li> + <li><span><a href="/en-US/Add-ons/Bootstrapped_extensions"><font><font>ملحقات Restartless قم</font></font></a></span><br> + <font><font>بتطوير ملحقات لا تتطلب إعادة تشغيل المستعرض.</font></font></li> + <li><a href="/en-US/Add-ons/Overlay_Extensions"><span><font><font>ملحقات التراكب قم</font></font></span></a><br> + <font><font>بتطوير</font><a href="/en-US/Add-ons/Overlay_Extensions"><span><font> الإضافات</font></span></a><font> التقليدية باستخدام تراكب XUL.</font></font></li> +</ul> + +<p><font><font>إذا استطعت ، فمن المستحسن استخدام أداة إضافة SDK الإضافية ، التي تستخدم آلية الإضافة دون إعادة التشغيل ، ولكن تبسط بعض المهام وتنظفها بعد نفسها. </font><font>إذا لم تكن حزمة إضافة SDK كافية لاحتياجاتك ، فقم بتطبيق ملحق إعادة التشغيل يدويًا بدلاً من ذلك.</font></font></p> + +<p><font><font>لمزيد من المعلومات حول اختيار التقنية المستخدمة ، اقرأ هذه </font></font><a href="/en-US/Add-ons/Comparing_Extension_Toolchains"><font><font>المقارنة</font></font></a><font><font> .</font></font></p> + +<div class="column-container"> +<div class="column-half"> +<h3 id="الممارسات_الجيدة"><font><font>الممارسات الجيدة</font></font></h3> + +<p><font><font>بغض النظر عن كيفية تطوير إضافة ، هناك بعض الإرشادات التي يمكنك اتباعها للمساعدة في التأكد من أن الإضافة توفر تجربة مستخدم جيدة قدر الإمكان.</font></font></p> + +<dl> + <dt><a href="/en-US/Add-ons/Performance_best_practices_in_extensions">Performance</a></dt> + <dd>Ensuring your extension is fast, responsive and memory-efficient.</dd> + <dt><a href="/en-US/Add-ons/Security_best_practices_in_extensions">Security</a></dt> + <dd>Ensuring your extension doesn't expose the user to malicious websites.</dd> + <dt><a href="/en-US/Add-ons/Extension_etiquette">Etiquette</a></dt> + <dd>Ensuring your extension plays nicely with other extensions.</dd> +</dl> +</div> + +<div class="column-half"> +<h3 id="Application-specific">Application-specific</h3> + +<p>Most of the documentation assumes you're developing for Firefox Desktop. If you're developing for some other Gecko-based application, there are major differences you need to know about.</p> + +<dl> + <dt><a href="/en-US/Add-ons/Thunderbird">Thunderbird</a></dt> + <dd>Developing extensions for the Thunderbird mail client.</dd> + <dt><a href="/en-US/Add-ons/Firefox_for_Android">Firefox for Android</a></dt> + <dd>Developing extensions for Firefox for Android.</dd> + <dt><a href="/en-US/Add-ons/SeaMonkey_2">SeaMonkey</a></dt> + <dd>Developing extensions for the <a href="http://www.seamonkey-project.org/">SeaMonkey</a> software suite.</dd> +</dl> +</div> +</div> + +<hr> +<h2 id="Themes_2"><a name="Themes">Themes</a></h2> + +<p>Themes are add-ons that customize the application's user interface. There are two sorts of themes: lightweight themes and complete themes.</p> + +<div class="column-container"> +<div class="column-half"> +<p><a href="https://addons.mozilla.org/en-US/developers/docs/themes">Lightweight themes</a> are much simpler to implement than complete themes, but provide very limited customization.</p> +</div> + +<div class="column-half"> +<p>With <a href="/en-US/docs/Themes">complete themes</a> you can make much deeper modifications to the application UI. The documentation for complete themes is out of date, but is linked to here as a possible basis for updated documentation.</p> +</div> +</div> + +<hr> +<h2 id="Other_types_of_add-ons">Other types of add-ons</h2> + +<p><a href="/en-US/docs/Creating_OpenSearch_plugins_for_Firefox">Search engine plugins</a> are a simple and very specific type of add-on: they add new search engines to the browser's search bar.</p> + +<p><strong><a href="/en-US/docs/Plugins">Plugins</a> </strong>help the application understand web content that it does not natively support. NPAPI plugins are a legacy technology and new sites should not use them. In general, plugins are not available on most modern mobile systems including, and websites should transition away from using plugins.</p> + +<p>{{AddonSidebar}}</p> diff --git a/files/ar/mozilla/add-ons/themes/index.html b/files/ar/mozilla/add-ons/themes/index.html new file mode 100644 index 0000000000..37dd0c7514 --- /dev/null +++ b/files/ar/mozilla/add-ons/themes/index.html @@ -0,0 +1,51 @@ +--- +title: Themes +slug: Mozilla/Add-ons/Themes +tags: + - Add-ons + - Look & Feel + - NeedsTranslation + - Themes + - TopicStub +translation_of: Mozilla/Add-ons/Themes +--- +<p>{{AddonSidebar}}</p> + +<p>Themes allow you to change the look and feel of the user interface and personalize it to your tastes. Learn how to create and share themes!</p> + +<div class="column-container"> +<div class="column-half"> +<h2 class="Documentation" id="Documentation" name="Documentation">Browser Themes</h2> + +<dl> + <dt><a href="/en-US/docs/Mozilla/Add-ons/Themes/Theme_concepts">Browser theme concepts</a></dt> + <dd>Get an introduction to creating themes for the latest versions of Firefox</dd> +</dl> + +<h2 class="Documentation" id="Documentation" name="Documentation">Lightweight Themes</h2> + +<dl> + <dt><a href="/en-US/docs/Themes/Lightweight_themes" title="Themes/Lightweight themes">Lightweight themes</a></dt> + <dd>Building lightweight themes for Firefox</dd> + <dt><a href="/en-US/Add-ons/Themes/Lightweight_Themes/FAQ">Lightweight themes FAQ</a></dt> + <dd>Get answers to commonly asked questions</dd> +</dl> +</div> + +<div class="column-half"> +<h2 id="Tools_Resources">Tools & Resources</h2> + +<ul> + <li><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/theme">Browser theme manifest.json keys</a></li> + <li><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/theme">Browser extensions theme API</a></li> + <li><a href="http://vanillaorchidstutorials.blogspot.com/2015/11/mozilla-themes-focal-point-sizing.html">Lightweight themes tutorial</a></li> + <li><a href="https://discourse.mozilla.org/c/add-ons/themes">Discourse forum</a></li> + <li><a href="https://blog.mozilla.org/addons/category/personas/">Theme related blog posts</a></li> + <li><a href="/en-US/Mozilla/Add-ons/Themes/Obsolete">Archived resources</a></li> +</ul> +</div> +</div> + +<p> </p> + +<p> </p> 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 +--- +<h4 id="sect1"></h4> + +<h4 id="AddonSidebar">{{AddonSidebar}}</h4> + +<p>Enables extensions to clear the data that is accumulated while the user is browsing.</p> + +<p>In the <code>browsingData</code> API, browsing data is divided into types:</p> + +<ul> + <li>browser cache</li> + <li>cookies</li> + <li>downloads</li> + <li>history</li> + <li>local storage</li> + <li>plugin data</li> + <li>saved form data</li> + <li>saved passwords</li> +</ul> + +<p>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.</p> + +<p>All the <code>browsingData.remove[X]()</code> functions take a {{WebExtAPIRef("browsingData.RemovalOptions")}} object, which you can use to control two further aspects of data removal:</p> + +<ul> + <li>how far back in time to remove data</li> + <li>whether to remove data only from normal web pages, or also from hosted web apps and add-ons. Note that this option is not yet supported in Firefox.</li> +</ul> + +<p>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.</p> + +<p>To use this API you must have the "browsingData" <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/permissions#API_permissions">API permission</a>.</p> + +<h2 id="Types">Types</h2> + +<dl> + <dt>{{WebExtAPIRef("browsingData.DataTypeSet")}}</dt> + <dd>Object used to specify the type of data to remove: for example, history, downloads, passwords, and so on.</dd> + <dt>{{WebExtAPIRef("browsingData.RemovalOptions")}}</dt> + <dd>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.</dd> +</dl> + +<h2 id="Methods">Methods</h2> + +<dl> + <dt>{{WebExtAPIRef("browsingData.remove()")}}</dt> + <dd>Removes browsing data for the data types specified.</dd> + <dt>{{WebExtAPIRef("browsingData.removeCache()")}}</dt> + <dd>Clears the browser's cache.</dd> + <dt>{{WebExtAPIRef("browsingData.removeCookies()")}}</dt> + <dd>Removes cookies.</dd> + <dt>{{WebExtAPIRef("browsingData.removeDownloads()")}}</dt> + <dd>Removes the list of downloaded files.</dd> + <dt>{{WebExtAPIRef("browsingData.removeFormData()")}}</dt> + <dd>Clears saved form data.</dd> + <dt>{{WebExtAPIRef("browsingData.removeHistory()")}}</dt> + <dd>Clears the browser's history.</dd> + <dt>{{WebExtAPIRef("browsingData.removeLocalStorage()")}}</dt> + <dd>Clears any <a href="/en-US/docs/Web/API/Window/localStorage">local storage</a> created by websites.</dd> + <dt>{{WebExtAPIRef("browsingData.removePasswords()")}}</dt> + <dd>Clears saved passwords.</dd> + <dt>{{WebExtAPIRef("browsingData.removePluginData()")}}</dt> + <dd>Clears data associated with plugins.</dd> + <dt>{{WebExtAPIRef("browsingData.settings()")}}</dt> + <dd>Gets the current value of settings in the browser's "Clear History" feature.</dd> +</dl> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + + + +<p>{{Compat("webextensions.api.browsingData", 2)}}</p> + +<div class="note hidden"> +<p>The "Chrome incompatibilities" section is included from <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities"> https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a> using the <a href="/en-US/docs/Template:WebExtChromeCompat">WebExtChromeCompat</a> macro.</p> + +<p>If you need to update this content, edit <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities">https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Chrome_incompatibilities</a>, then shift-refresh this page to see your changes.</p> +</div> + +<p>{{WebExtExamples("h2")}}</p> + +<div class="note"><strong>Acknowledgements</strong> + +<p>This API is based on Chromium's <a href="https://developer.chrome.com/extensions/browsingData"><code>chrome.browsingData</code></a> API.</p> + +<p>Microsoft Edge compatibility data is supplied by Microsoft Corporation and is included here under the Creative Commons Attribution 3.0 United States License.</p> +</div> + +<div class="hidden"> +<pre class="notranslate">// Copyright 2015 The Chromium Authors. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following disclaimer +// in the documentation and/or other materials provided with the +// distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</pre> +</div> 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 +--- +<div>{{AddonSidebar}}</div> + +<p>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.</p> + +<p>This API is very similar to the <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts">"content_scripts"</a></code> manifest.json key, except that with <code>"content_scripts"</code> , the set of content scripts and associated patterns is fixed at install time. With the <code>contentScripts</code> API, an extension can register and unregister scripts at runtime.</p> + +<p>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 <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code> that is resolved with a {{WebExtAPIRef("contentScripts.RegisteredContentScript")}} object.</p> + +<p>The <code>RegisteredContentScript</code> object represents the scripts that were registered in the <code>register()</code> call. It defines an <code>unregister()</code> 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.</p> + +<p>There is no <code>contentScripts</code> API permission, but an extension must have the appropriate <a href="/en-US/Add-ons/WebExtensions/manifest.json/permissions#Host_permissions">host permissions</a> for any patterns it passes to <code>register()</code>.</p> + +<h2 id="Types">Types</h2> + +<dl> + <dt>{{WebExtAPIRef("contentScripts.RegisteredContentScript")}}</dt> + <dd> + <p>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.</p> + </dd> +</dl> + +<h2 id="Functions">Functions</h2> + +<dl> + <dt>{{WebExtAPIRef("contentScripts.register()")}}</dt> + <dd>Registers the given content scripts.</dd> +</dl> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<p>{{Compat("webextensions.api.contentScripts", 10, 1)}}</p> + +<p> {{WebExtExamples("h2")}}</p> 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 +--- +<div>{{AddonSidebar}}</div> + +<div> +<p>JavaScript APIs for WebExtensions can be used inside the extension's <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Background_scripts">background scripts</a> and in any other documents bundled with the extension, including <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Browser_action">browser action</a> or <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Page_actions">page action</a> popups, <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Sidebars">sidebars</a>, <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Options_pages">options pages</a>, or <a href="/en-US/Add-ons/WebExtensions/manifest.json/chrome_url_overrides">new tab pages</a>. A few of these APIs can also be accessed by an extension's <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Anatomy_of_a_WebExtension#Content_scripts">content scripts</a> (see the <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_scripts#WebExtension_APIs">list in the content script guide</a>).</p> + +<p>To use the more powerful APIs you need to <a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions/manifest.json/permissions">request permission</a> in your extension's manifest.json.</p> + +<p>You can access the APIs using the <code>browser</code> namespace:</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">logTabs</span><span class="punctuation token">(</span>tabs<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>tabs<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +browser<span class="punctuation token">.</span>tabs<span class="punctuation token">.</span><span class="function token">query</span><span class="punctuation token">(</span><span class="punctuation token">{</span>currentWindow<span class="punctuation token">:</span> <span class="keyword token">true</span><span class="punctuation token">}</span><span class="punctuation token">,</span> logTabs<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> +</div> + +<div> +<p>Many of the APIs are asynchronous, returning a <code><a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise">Promise</a></code>:</p> + +<pre class="brush: js line-numbers language-js"><code class="language-js"><span class="keyword token">function</span> <span class="function token">logCookie</span><span class="punctuation token">(</span>c<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">log</span><span class="punctuation token">(</span>c<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">function</span> <span class="function token">logError</span><span class="punctuation token">(</span>e<span class="punctuation token">)</span> <span class="punctuation token">{</span> + console<span class="punctuation token">.</span><span class="function token">error</span><span class="punctuation token">(</span>e<span class="punctuation token">)</span><span class="punctuation token">;</span> +<span class="punctuation token">}</span> + +<span class="keyword token">var</span> setCookie <span class="operator token">=</span> browser<span class="punctuation token">.</span>cookies<span class="punctuation token">.</span><span class="keyword token">set</span><span class="punctuation token">(</span> + <span class="punctuation token">{</span>url<span class="punctuation token">:</span> <span class="string token">"https://developer.mozilla.org/"</span><span class="punctuation token">}</span> +<span class="punctuation token">)</span><span class="punctuation token">;</span> +setCookie<span class="punctuation token">.</span><span class="function token">then</span><span class="punctuation token">(</span>logCookie<span class="punctuation token">,</span> logError<span class="punctuation token">)</span><span class="punctuation token">;</span></code></pre> +</div> + +<div> +<p>Note that this is different from Google Chrome's extension system, which uses the <code>chrome</code> namespace instead of <code>browser</code>, and which uses callbacks instead of promises for asynchronous functions. As a porting aid, the Firefox implementation of WebExtensions APIs supports <code>chrome</code> and callbacks as well as <code>browser</code> and promises. Mozilla has also written a polyfill which enables code that uses <code>browser</code> and promises to work unchanged in Chrome: <a class="external external-icon" href="https://github.com/mozilla/webextension-polyfill">https://github.com/mozilla/webextension-polyfill</a>.</p> + +<p>Firefox also implements these APIs under the <code>chrome</code> namespace using callbacks. This allows code written for Chrome to run largely unchanged in Firefox for the APIs documented here.</p> + +<p>Microsoft Edge uses the <code>browser</code> namespace, but doesn't yet support promise-based asynchronous APIs. In Edge, for the time being, asynchronous APIs must use callbacks.</p> + +<p>Not all browsers support all the APIs: for the details, see <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs">Browser support for JavaScript APIs</a>.</p> +</div> + +<div>{{SubpagesWithSummaries}}</div> diff --git a/files/ar/mozilla/add-ons/webextensions/index.html b/files/ar/mozilla/add-ons/webextensions/index.html new file mode 100644 index 0000000000..387f9bf8ac --- /dev/null +++ b/files/ar/mozilla/add-ons/webextensions/index.html @@ -0,0 +1,131 @@ +--- +title: امتدادات المتصفح +slug: Mozilla/Add-ons/WebExtensions +tags: + - إضافات + - صفحة هبوط +translation_of: Mozilla/Add-ons/WebExtensions +--- +<div class="boxed translate-rendered text-content"> +<div>{{AddonSidebar}}</div> + +<p dir="rtl">تستطيع الامتدادات (extensions) أن تزيد وتُعدِل من إمكانيّة المُتصفِح. امتدادات فايرفوكس مبنيّة بواسطة الواجهة البرمجيّة المسماة WebExtensions، وهي نظام عابر للمتصفحات (cross-browser) لتطوير الإضافات. يتوافق النظام إلى حدٍ كبير مع <a href="https://developer.chrome.com/extensions">واجهة الإضافات البرمجيّة</a> المدعومة بواسطة متصفخ جوجل كروم وأوبرا، كما يتوافق مع <a href="https://browserext.github.io/browserext/">مسودة W3C المجتمعيّة</a>. الإضافات المكتوبة لتلك المتصفحات ستعمل على فايرفوكس و<a href="https://developer.microsoft.com/en-us/microsoft-edge/platform/documentation/extensions/">مايكروسوفت أيدج</a> في معظم الحالات <a href="/ar/Add-ons/WebExtensions/Porting_from_Google_Chrome">بتغييرات طفيفة</a>. الواجهة البرمجيّة متوافقة أيضاً مع <a href="/ar/Firefox/Multiprocess_Firefox">فايرفوكس متعدد العمليات</a> (multiprocess firefox).</p> + +<p dir="rtl">إذا كانت لديك أسئلة أو أفكار، أو تريد مساعدة في نقل إضافة قديمة وجعلها تستخدم الواجهة البرمجيّة الحديثة، يمكنك التواصل معنا عبر <a href="https://mail.mozilla.org/listinfo/dev-addons">قائمة مطورين الإضافات البريديّة</a> أو على قناة <a href="irc://irc.mozilla.org/webextensions">webextensions#</a>.</p> + +<div class="row topicpage-table"> +<div class="section"> +<h2 dir="rtl" id="دليل_البداية">دليل البداية</h2> + +<ul dir="rtl"> + <li><a href="/ar/Add-ons/WebExtensions/What_are_WebExtensions">ما هي الإضافات؟</a></li> + <li><a href="/ar/Add-ons/WebExtensions/Your_first_WebExtension">إضافتك الأولى</a></li> + <li><a href="/ar/Add-ons/WebExtensions/Your_second_WebExtension">إضافتك الثانية</a></li> + <li><a href="/ar/Add-ons/WebExtensions/Anatomy_of_a_WebExtension">تشريح بنيّة الإضافات</a></li> + <li><a href="/ar/Add-ons/WebExtensions/Examples">أمثلة عن الإضافات</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/What_next_">ما الخطوة التالية؟</a></li> +</ul> + +<h2 dir="rtl" id="مفاهيم">مفاهيم</h2> + +<ul dir="rtl"> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/API">لمحة عن واجهات جافاسكربت البرمجيّة</a></li> + <li><a href="/ar/Add-ons/WebExtensions/Content_scripts">محتويات البرمجيات</a> (content scripts)</li> + <li><a href="/ar/Add-ons/WebExtensions/Match_patterns">مطابقة الأنماط</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Working_with_files">العمل مع الملفات</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Internationalization">ترجمة الإضافات</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Security_best_practices">أفضل الأساليب الأمنيّة</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Content_Security_Policy">سياسة خصوصيّة المحتوى</a> (Content Security Policy)</li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Native_messaging">التواصل المحلي</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Using_the_devtools_APIs">استخدام واجهات مطورين الأدوات البرمجيّة</a></li> + <li><a href="/ar/Add-ons/WebExtensions/User_experience_best_practices">أفضل الأساليب في تجربة المستخدم</a></li> + <li><a href="/ar/Add-ons/WebExtensions/Native_manifests">ملفات manifest المحليّة</a></li> +</ul> + +<h2 dir="rtl" id="واجهة_المستخدم">واجهة المستخدم</h2> + +<ul dir="rtl"> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/user_interface">مقدمة</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/user_interface/Browser_action">زر في شريط أدوات المتصفح</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/user_interface/Popups">زر في شريط أدوات المتصفح مع نافذة مُنبثِقة</a> (popup)</li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/user_interface/Page_actions">زر في شريط العنوان</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/user_interface/Popups">زر في شريط العنوان مع نافذة مُنبثِقة</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/user_interface/Context_menu_items">العناصر في قائمة السياق</a> (القائمة التي تظهر عند ضغط زر الفأرة الأيمن في المتصفح)</li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/user_interface/Sidebars">الأشرطة الجانبيّة</a> (sidebars)</li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/user_interface/Options_pages">صفحة الإعدادات (الخيارات)</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/user_interface/Extension_pages">صفحات الإضافة</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/user_interface/Notifications">الإشعارات</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/user_interface/Omnibox">الإقتراحات في شريط العنوان</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/user_interface/devtools_panels">لوحات أدوات المطورين</a></li> +</ul> + +<h2 dir="rtl" id="مقالات_كيف_تقوم_بـ">مقالات "كيف تقوم بـ"</h2> + +<ul dir="rtl"> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Intercept_HTTP_requests">اعتراض طلبات ميثاق نقل النص الفائق</a> (HTTP)</li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Modify_a_web_page">تعديل الصفحات</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Add_a_button_to_the_toolbar">إضافة زر لشريط الأدوات</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Implement_a_settings_page">إضافة صفحة إعدادات</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Interact_with_the_clipboard">التفاعل مع الحافظة</a> (clipboard)</li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Working_with_the_Tabs_API">العمل مع واجهة النوافذ البرمجيّة</a> (Tabs API)</li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Work_with_the_Bookmarks_API">العمل مع واجهة العلامات المرجعيّة البرمجيّة</a> (Bookmarks API)</li> + <li><a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/Work_with_the_Cookies_API">العمل مع واجهة الكعكات البرمجيّة</a> (Cookies API)</li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Work_with_contextual_identities">العمل مع الهويات السياقيّة</a> (contextual identities)</li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Safely_inserting_external_content_into_a_page">إدخال محتوى خارجي</a></li> +</ul> + +<ul> +</ul> + +<h2 dir="rtl" id="الترحيل">الترحيل</h2> + +<ul dir="rtl"> + <li><a href="/ar/Add-ons/WebExtensions/Porting_from_Google_Chrome">ترحيل (Porting) إضافة جوجل كروم</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Porting_a_legacy_Firefox_add-on">ترحيل إضافة فايرفوكس قديمة</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Developing_WebExtensions_for_Firefox_for_Android">تطوير إضافات فايرفوكس للأندرويد</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Embedded_WebExtensions">إضافات الويب (WebExtension) المضمنة</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Comparison_with_the_Add-on_SDK">مقارنة مع حزمة أدوات Add-on</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Comparison_with_XUL_XPCOM_extensions">مقارنة مع إضافات XUL و XPCOM</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Chrome_incompatibilities">الأمور الغير متوافقة مع كروم</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Differences_between_desktop_and_Android">الإختلافات بين إضافات سطح المكتب والأندرويد</a></li> +</ul> + +<h2 dir="rtl" id="سير_العمل_مع_فيرفوكس">سير العمل مع فيرفوكس</h2> + +<ul dir="rtl"> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/User_experience_best_practices">تجربة المُستخدِم</a></li> + <li><a href="/ar/Add-ons/WebExtensions/Temporary_Installation_in_Firefox">التثبيت</a></li> + <li><a href="/ar/Add-ons/WebExtensions/Debugging">تصحيح الأخطاء (التنقيح)</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Testing_persistent_and_restart_features">الاختبار المستمر وتكرار الميزات</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Getting_started_with_web-ext">الشروع بالعمل مع أداة web-ext</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/WebExtensions_and_the_Add-on_ID">مُعرِف الإضافات</a></li> + <li><a href="/ar/Add-ons/WebExtensions/Alternative_distribution_options">خيارات توزيع بديلة </a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Request_the_right_permissions">طلب الأذونات المناسبة</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Sharing_objects_with_page_scripts">مشاركة الكائنات بين الصفحات</a></li> + <li><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Retiring_your_extension">إقعاد (إيقاف تطوير) إضافتك</a></li> +</ul> +</div> + +<div class="section"> +<h2 dir="rtl" id="مراجع">مراجع</h2> + +<h3 dir="rtl" id="واجهات_جافاسكربت_البرمجيّة">واجهات جافاسكربت البرمجيّة</h3> + +<ul dir="rtl"> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/API">لمحة عن واجهة جافاسكربت البرمجيّة</a></li> + <li><a href="/ar/Add-ons/WebExtensions/Browser_support_for_JavaScript_APIs">جداول توافقيّة واجهات جافاسكربت البرمجيّة مع المتصفحات</a></li> +</ul> + +<div class="twocolumns">{{ ListSubpages ("/ar/Add-ons/WebExtensions/API") }}</div> + +<h3 dir="rtl" id="قيم_ملف_Manifest">قيم ملف Manifest</h3> + +<ul dir="rtl"> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/manifest.json">لمحة عن ملف manifest.json</a></li> + <li><a href="/ar/docs/Mozilla/Add-ons/WebExtensions/Browser_compatibility_for_manifest.json">توافق المتصفحات مع ملف manifest.json</a></li> +</ul> + +<div class="twocolumns">{{ ListSubpages ("/ar/Add-ons/WebExtensions/manifest.json") }}</div> +</div> +</div> +</div> diff --git a/files/ar/mozilla/add-ons/webextensions/manifest.json/content_scripts/index.html b/files/ar/mozilla/add-ons/webextensions/manifest.json/content_scripts/index.html new file mode 100644 index 0000000000..ac1c401c35 --- /dev/null +++ b/files/ar/mozilla/add-ons/webextensions/manifest.json/content_scripts/index.html @@ -0,0 +1,223 @@ +--- +title: content_scripts +slug: Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts +translation_of: Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts +--- +<div>{{AddonSidebar}}</div> + +<table class="fullwidth-table standard-table"> + <tbody> + <tr> + <th scope="row" style="width: 30%;">Type</th> + <td><code>Array</code></td> + </tr> + <tr> + <th scope="row">Mandatory</th> + <td>No</td> + </tr> + <tr> + <th scope="row">Example</th> + <td> + <pre class="brush: json no-line-numbers"> +"content_scripts": [ + { + "matches": ["*://*.mozilla.org/*"], + "js": ["borderify.js"] + } +]</pre> + </td> + </tr> + </tbody> +</table> + +<p>Instructs the browser to load <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">content scripts</a> into web pages whose URL matches a given pattern.</p> + +<p>This key is an array. Each item is an object which:</p> + +<ul> + <li><strong>must</strong> contain a key named <strong><code>matches</code></strong>, that specifies the URL patterns to be matched in order for the scripts to be loaded</li> + <li><strong>may</strong> contain keys named <strong><code>js</code></strong> and <strong><code>css</code></strong>, which list scripts to be loaded into matching pages</li> + <li><strong>may</strong> contain a number of other properties that control finer aspects of how and when content scripts are loaded</li> +</ul> + +<p>Details of all the keys you can include are given in the table below.</p> + +<table class="fullwidth-table standard-table"> + <thead> + <tr> + <th scope="col">Name</th> + <th scope="col">Type</th> + <th scope="col">Description</th> + </tr> + </thead> + <tbody> + <tr> + <td><a id="all_frames" name="all_frames"><code>all_frames</code></a></td> + <td><code>Boolean</code></td> + <td> + <p><code>true</code>: inject the scripts specified in <code><a href="#js">js</a></code> and <code><a href="#css">css</a></code> into all frames matching the specified URL requirements, even if the frame is not the topmost frame in a tab. This does not inject into child frames where only their parent matches the URL requirements and the child frame does not match the URL requirements. The URL requirements are checked for each frame independently.</p> + + <p><code>false</code>: inject only into frames matching the URL requirements which are the topmost frame in a tab.</p> + + <p>Defaults to <code>false</code>.</p> + </td> + </tr> + <tr> + <td><a id="css" name="css"><code>css</code></a></td> + <td><code>Array</code></td> + <td> + <p>An array of paths, relative to manifest.json, referencing CSS files that will be injected into matching pages.</p> + + <p>Files are injected in the order given, and before the DOM is loaded.</p> + </td> + </tr> + <tr> + <td><a id="exclude_globs" name="exclude_globs"><code>exclude_globs</code></a></td> + <td><code>Array</code></td> + <td>An array of strings containing wildcards. See <a href="/en-US/Add-ons/WebExtensions/manifest.json/content_scripts#Matching_URL_patterns">Matching URL patterns</a> below.</td> + </tr> + <tr> + <td><a id="exclude_matches" name="exclude_matches"><code>exclude_matches</code></a></td> + <td><code>Array</code></td> + <td>An array of <a href="/en-US/Add-ons/WebExtensions/match_patterns">match patterns</a>. See <a href="/en-US/Add-ons/WebExtensions/manifest.json/content_scripts#Matching_URL_patterns">Matching URL patterns</a> below.</td> + </tr> + <tr> + <td><a id="include_globs" name="include_globs"><code>include_globs</code></a></td> + <td><code>Array</code></td> + <td>An array of strings containing wildcards. See <a href="/en-US/Add-ons/WebExtensions/manifest.json/content_scripts#Matching_URL_patterns">Matching URL patterns</a> below.</td> + </tr> + <tr> + <td><a id="js" name="js"><code>js</code></a></td> + <td><code>Array</code></td> + <td> + <p>An array of paths, relative to the manifest.json file, referencing JavaScript files that will be injected into matching pages.</p> + + <p>Files are injected in the order given. This means that, for example, if you include jQuery here followed by another content script, like this:</p> + + <pre class="brush: json no-line-numbers"> +<code>"js": ["jquery.js", "my-content-script.js"]</code></pre> + + <p>then <code>"my-content-script.js"</code> can use jQuery.</p> + + <p>Files are injected at the time specified by <code><a href="#run_at">run_at</a></code>.</p> + </td> + </tr> + <tr> + <td><code><a id="match_about_blank" name="match_about_blank">match_about_blank</a></code></td> + <td><code>Boolean</code></td> + <td> + <p>Insert the content scripts into pages whose URL is "about:blank" or "about:srcdoc", if the URL of the page that opened or created this page <a href="/en-US/Add-ons/WebExtensions/manifest.json/content_scripts#Matching_URL_patterns">matches the patterns</a> specified in the rest of the <code>content_scripts</code> key.</p> + + <p>This is especially useful to run scripts in empty iframes , whose URL is "about:blank". To do this you should also set the <code>all_frames</code> key.</p> + + <p>For example, suppose you have a <code>content_scripts</code> key like this:</p> + + <pre class="brush: json no-line-numbers"> + "content_scripts": [ + { + "js": ["my-script.js"], + "matches": ["https://example.org/"], + "match_about_blank": true, + "all_frames": true + } + ]</pre> + + <p>If the user loads https://example.org/, and this page embeds an empty iframe, then "my-script.js" will be loaded into the iframe.</p> + + <p><code>match_about_blank</code> is supported in Firefox from version 52. Note that in Firefox, content scripts won't be injected into empty iframes at <code>"document_start"</code> even if you specify that value in <code><a href="/en-US/Add-ons/WebExtensions/manifest.json/content_scripts#run_at">run_at</a></code>.</p> + </td> + </tr> + <tr> + <td><a id="matches" name="matches"><code>matches</code></a></td> + <td><code>Array</code></td> + <td> + <p>An array of <a href="/en-US/Add-ons/WebExtensions/match_patterns">match patterns</a>. See <a href="/en-US/Add-ons/WebExtensions/manifest.json/content_scripts#Matching_URL_patterns">Matching URL patterns</a> below.</p> + + <p>This is the only mandatory key.</p> + </td> + </tr> + <tr> + <td><a id="run_at" name="run_at"><code>run_at</code></a></td> + <td><code>String</code></td> + <td> + <p>This option determines when the scripts specified in <code><a href="#js">js</a></code> are injected. You can supply one of three strings here, each of which identifies a state in the process of loading a document. The states directly correspond to {{domxref("Document/readyState", "Document.readyState")}}:</p> + + <ul> + <li>"<code>document_start</code>": corresponds to <code>loading</code>. The DOM is still loading.</li> + <li>"<code>document_end</code>": corresponds to <code>interactive</code>. The DOM has finished loading, but resources such as scripts and images may still be loading.</li> + <li>"<code>document_idle</code>": corresponds to <code>complete</code>. The document and all its resources have finished loading.</li> + </ul> + + <p>The default value is <code>"document_idle"</code>.</p> + + <p>In all cases, files in <code><a href="#js">js</a></code> are injected after files in <code><a href="#css">css</a></code>.</p> + </td> + </tr> + </tbody> +</table> + +<h2 id="Matching_URL_patterns">Matching URL patterns</h2> + +<p>The <code>"content_scripts"</code> key attaches content scripts to documents based on URL matching: if the document's URL matches the specification in the key, then the script will be attached. There are four properties inside <code>"content_scripts"</code> that you can use for this specification:</p> + +<ul> + <li><code>matches</code>: an array of <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns">match patterns</a>.</li> + <li><code>exclude_matches:</code> an array of <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Match_patterns">match patterns</a>.</li> + <li><code>include_globs</code>: an array of <a href="#globs">globs</a>.</li> + <li><code>exclude_globs:</code> an array of <a href="#globs">globs</a>.</li> +</ul> + +<p>To match one of these properties, a URL must match at least one of the items in its array. For example, given a property like:</p> + +<pre class="brush: json no-line-numbers">"matches": ["*://*.example.org/*", "*://*.example.com/*"]</pre> + +<p>Both "http://example.org/" and "http://example.com/" will match.</p> + +<p>Since <code>matches</code> is the only mandatory key, the other three keys are use to limit further the URLs that match. To match the key as a whole, a URL must:</p> + +<ol> + <li>match the <code>matches</code> property</li> + <li>AND match the <code>include_globs</code> property, if present</li> + <li>AND NOT match the <code>exclude_matches</code> property, if present</li> + <li>AND NOT match the <code>exclude_globs</code> property, if present</li> +</ol> + +<h3 id="globs">globs</h3> + +<p>A glob is just a string that may contain wildcards. There are two types of wildcard, and you can combine them in the same glob:</p> + +<ul> + <li>"*" matches zero or more characters</li> + <li>"?" matches exactly one character.</li> +</ul> + +<p>For example: <code>"*na?i"</code> would match <code>"illuminati"</code> and <code>"annunaki"</code>, but not <code>"sagnarelli"</code>.</p> + +<h2 id="Example">Example</h2> + +<pre class="brush: json no-line-numbers">"content_scripts": [ + { + "matches": ["*://*.mozilla.org/*"], + "js": ["borderify.js"] + } +]</pre> + +<p>This injects a single content script "borderify.js" into all pages under "mozilla.org" or any of its subdomains, whether served over HTTP or HTTPS.</p> + +<pre class="brush: json no-line-numbers"> "content_scripts": [ + { + "exclude_matches": ["*://developer.mozilla.org/*"], + "matches": ["*://*.mozilla.org/*"], + "js": ["jquery.js", "borderify.js"] + } + ]</pre> + +<p>This injects two content scripts into all pages under "mozilla.org" or any of its subdomains except "developer.mozilla.org", whether served over HTTP or HTTPS.</p> + +<p>The content scripts see the same view of the DOM and are injected in the order they appear in the array, so "borderify.js" can see global variables added by "jquery.js".</p> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("webextensions.manifest.content_scripts")}}</p> diff --git a/files/ar/mozilla/add-ons/webextensions/manifest.json/index.html b/files/ar/mozilla/add-ons/webextensions/manifest.json/index.html new file mode 100644 index 0000000000..332566c368 --- /dev/null +++ b/files/ar/mozilla/add-ons/webextensions/manifest.json/index.html @@ -0,0 +1,109 @@ +--- +title: manifest.json +slug: Mozilla/Add-ons/WebExtensions/manifest.json +tags: + - Add-ons + - Extensions + - NeedsTranslation + - TopicStub + - WebExtensions +translation_of: Mozilla/Add-ons/WebExtensions/manifest.json +--- +<div>{{AddonSidebar}}</div> + +<p>The manifest.json file is a <a href="/en-US/docs/Glossary/JSON">JSON</a>-formatted file, and is the only file that every extension using WebExtension APIs must contain.</p> + +<p>Using manifest.json, you specify basic metadata about your extension such as the name and version, and can also specify aspects of your extension's functionality, such as background scripts, content scripts, and browser actions.</p> + +<p>manifest.json keys are listed below:</p> + +<div class="twocolumns">{{ ListSubpages ("/en-US/Add-ons/WebExtensions/manifest.json") }}</div> + +<div class="twocolumns"> </div> + +<p><code>"manifest_version"</code>, <code>"version"</code>, and <code>"name"</code> are the only mandatory keys. <code>"default_locale"</code> must be present if the "_locales" directory is present and must be absent otherwise. <code>"applications"</code> is not supported in Google Chrome, and is mandatory in Firefox before Firefox 48 and Firefox for Android.</p> + +<p>You can access your extension's manifest from the extension's JavaScript using the {{WebExtAPIRef("runtime.getManifest()")}} function:</p> + +<pre class="brush: js">browser.runtime.getManifest().version;</pre> + +<h2 id="Browser_compatibility">Browser compatibility</h2> + +<p>{{Compat("webextensions.manifest")}}</p> + +<h2 id="Example">Example</h2> + +<p>Quick syntax example for manifest.json:</p> + +<pre class="brush: json">{ + "applications": { + "gecko": { + "id": "addon@example.com", + "strict_min_version": "42.0" + } + }, + + "background": { + "scripts": ["jquery.js", "my-background.js"], + "page": "my-background.html" + }, + + "browser_action": { + "default_icon": { + "19": "button/geo-19.png", + "38": "button/geo-38.png" + }, + "default_title": "Whereami?", + "default_popup": "popup/geo.html" + }, + + "commands": { + "toggle-feature": { + "suggested_key": { + "default": "Ctrl+Shift+Y", + "linux": "Ctrl+Shift+U" + }, + "description": "Send a 'toggle-feature' event" + } + }, + + "content_security_policy": "script-src 'self' https://example.com; object-src 'self'", + + "content_scripts": [ + { + "exclude_matches": ["*://developer.mozilla.org/*"], + "matches": ["*://*.mozilla.org/*"], + "js": ["borderify.js"] + } + ], + + "default_locale": "en", + + "description": "...", + + "icons": { + "48": "icon.png", + "96": "icon@2x.png" + }, + + "manifest_version": 2, + + "name": "...", + + "page_action": { + "default_icon": { + "19": "button/geo-19.png", + "38": "button/geo-38.png" + }, + "default_title": "Whereami?", + "default_popup": "popup/geo.html" + }, + + "permissions": ["webNavigation"], + + "version": "0.1", + + "web_accessible_resources": ["images/my-image.png"] +}</pre> + +<p> </p> diff --git a/files/ar/mozilla/add-ons/webextensions/match_patterns/index.html b/files/ar/mozilla/add-ons/webextensions/match_patterns/index.html new file mode 100644 index 0000000000..d5775418be --- /dev/null +++ b/files/ar/mozilla/add-ons/webextensions/match_patterns/index.html @@ -0,0 +1,449 @@ +--- +title: Match patterns +slug: Mozilla/Add-ons/WebExtensions/Match_patterns +translation_of: Mozilla/Add-ons/WebExtensions/Match_patterns +--- +<div>{{AddonSidebar}}</div> + +<p>Match patterns are a way to specify groups of URLs: a match pattern matches a specific set of URLs. They are for extensions using WebExtensions APIs in a few places, most notably to specify which documents to load <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Content_scripts">content scripts</a> into, and to specify which URLs to add <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest">webRequest</a></code> listeners to.</p> + +<p>APIs that use match patterns usually accept a list of match patterns, and will perform the appropriate action if the URL matches any of the patterns. See, for example, the <code><a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/content_scripts">content_scripts</a></code> key in manifest.json.</p> + +<h2 id="Match_pattern_structure">Match pattern structure</h2> + +<p>All match patterns are specified as strings. Apart from the special <a href="/en-US/Add-ons/WebExtensions/Match_patterns#%3Call_urls%3E">"<all_urls>"</a> pattern, match patterns consist of three parts: <em>scheme</em>, <em>host</em>, and <em>path</em>. The scheme and host are separated by "://".</p> + +<pre><scheme>://<host><path></pre> + +<h3 id="scheme">scheme</h3> + +<p>The <em>scheme</em> component may take one of two forms:</p> + +<table class="fullwidth-table standard-table"> + <thead> + <tr> + <th scope="col" style="width: 50%;">Form</th> + <th scope="col">Matches</th> + </tr> + </thead> + <tbody> + <tr> + <td>"*"</td> + <td>Only "http" and "https".</td> + </tr> + <tr> + <td>One of "http", "https", "file", "ftp", "app".</td> + <td>Only the given scheme.</td> + </tr> + </tbody> +</table> + +<h3 id="host">host</h3> + +<p>The <em>host</em> component may take one of three forms:</p> + +<table class="fullwidth-table standard-table"> + <thead> + <tr> + <th scope="col" style="width: 50%;">Form</th> + <th scope="col">Matches</th> + </tr> + </thead> + <tbody> + <tr> + <td>"*"</td> + <td>Any host.</td> + </tr> + <tr> + <td>"*." followed by part of the hostname.</td> + <td>The given host and any of its subdomains.</td> + </tr> + <tr> + <td>A complete hostname, without wildcards.</td> + <td>Only the given host.</td> + </tr> + </tbody> +</table> + +<p><em>host</em> is optional only if the <em>scheme</em> is "file".</p> + +<p>Note that the wildcard may only appear at the start.</p> + +<h3 id="path">path</h3> + +<p>The path component must begin with a "/".</p> + +<p>After that, it may subsequently contain any combination of the "*" wildcard and any of the characters that are allowed in URL paths. Unlike <em>host</em>, the <em>path</em> component may contain the "*" wildcard in the middle or at the end, and the "*" wildcard may appear more than once.</p> + +<h3 id="<all_urls>"><all_urls></h3> + +<p>The special value "<all_urls>" matches all URLs under any of the supported schemes: that is, "http", "https", "file", "ftp", "app".</p> + +<h2 id="Examples">Examples</h2> + +<table class="fullwidth-table standard-table"> + <thead> + <tr> + <th scope="col" style="width: 33%;">Pattern</th> + <th scope="col" style="width: 33%;">Example matches</th> + <th scope="col" style="width: 33%;">Example non-matches</th> + </tr> + </thead> + <tbody> + <tr> + <td> + <p><code><all_urls></code></p> + + <p>Match all URLs.</p> + </td> + <td> + <p><code>http://example.org/</code></p> + + <p><code>ftp://files.somewhere.org/</code></p> + + <p><code>https://a.org/some/path/</code></p> + </td> + <td> + <p><code>resource://a/b/c/</code><br> + (unsupported scheme)</p> + </td> + </tr> + <tr> + <td> + <p><code>*://*.mozilla.org/*</code></p> + + <p>Match all HTTP and HTTPS URLs that are hosted at "mozilla.org" or one of its subdomains.</p> + </td> + <td> + <p><code>http://mozilla.org/</code></p> + + <p><code>https://mozilla.org/</code></p> + + <p><code>http://a.mozilla.org/</code></p> + + <p><code>http://a.b.mozilla.org/</code></p> + + <p><code>https://b.mozilla.org/path/</code></p> + </td> + <td> + <p><code>ftp://mozilla.org/</code><br> + (unmatched scheme)</p> + + <p><code>http://mozilla.com/</code><br> + (unmatched host)</p> + + <p><code>http://firefox.org/</code><br> + (unmatched host)</p> + </td> + </tr> + <tr> + <td> + <p><code>*://mozilla.org/</code></p> + + <p>Match all HTTP and HTTPS URLs that are hosted at exactly "mozilla.org/".</p> + </td> + <td> + <p><code>http://mozilla.org/</code></p> + + <p><code>https://mozilla.org/</code></p> + </td> + <td> + <p><code>ftp://mozilla.org/</code><br> + (unmatched scheme)</p> + + <p><code>http://a.mozilla.org/</code><br> + (unmatched host)</p> + + <p><code>http://mozilla.org/a</code><br> + (unmatched path)</p> + </td> + </tr> + <tr> + <td> + <p><code>ftp://mozilla.org/</code></p> + + <p>Match only "ftp://mozilla.org/".</p> + </td> + <td><code>ftp://mozilla.org</code></td> + <td> + <p><code>http://mozilla.org/</code><br> + (unmatched scheme)</p> + + <p><code>ftp://sub.mozilla.org/</code><br> + (unmatched host)</p> + + <p><code>ftp://mozilla.org/path</code><br> + (unmatched path)</p> + </td> + </tr> + <tr> + <td> + <p><code>https://*/path</code></p> + + <p>Match HTTPS URLs on any host, whose path is "path".</p> + </td> + <td> + <p><code>https://mozilla.org/path</code></p> + + <p><code>https://a.mozilla.org/path</code></p> + + <p><code>https://something.com/path</code></p> + </td> + <td> + <p><code>http://mozilla.org/path</code><br> + (unmatched scheme)</p> + + <p><code>https://mozilla.org/path/</code><br> + (unmatched path)</p> + + <p><code>https://mozilla.org/a</code><br> + (unmatched path)</p> + + <p><code>https://mozilla.org/</code><br> + (unmatched path)</p> + </td> + </tr> + <tr> + <td> + <p><code>https://*/path/</code></p> + + <p>Match HTTPS URLs on any host, whose path is "path/".</p> + </td> + <td> + <p><code>https://mozilla.org/path/</code></p> + + <p><code>https://a.mozilla.org/path/</code></p> + + <p><code>https://something.com/path</code>/</p> + </td> + <td> + <p><code>http://mozilla.org/path/</code><br> + (unmatched scheme)</p> + + <p><code>https://mozilla.org/path</code><br> + (unmatched path)</p> + + <p><code>https://mozilla.org/a</code><br> + (unmatched path)</p> + + <p><code>https://mozilla.org/</code><br> + (unmatched path)</p> + </td> + </tr> + <tr> + <td> + <p><code>https://mozilla.org/*</code></p> + + <p>Match HTTPS URLs only at "mozilla.org", with any path.</p> + </td> + <td> + <p><code>https://mozilla.org/</code></p> + + <p><code>https://mozilla.org/path</code></p> + + <p><code>https://mozilla.org/another</code></p> + + <p><code>https://mozilla.org/path/to/doc</code></p> + </td> + <td> + <p><code>http://mozilla.org/path</code><br> + (unmatched scheme)</p> + + <p><code>https://mozilla.com/path</code><br> + (unmatched host)</p> + </td> + </tr> + <tr> + <td> + <p><code>https://mozilla.org/a/b/c/</code></p> + + <p>Match only this URL.</p> + </td> + <td><code>https://mozilla.org/a/b/c/</code></td> + <td>Anything else.</td> + </tr> + <tr> + <td> + <p><code>https://mozilla.org/*/b/*/</code></p> + + <p>Match HTTPS URLs hosted on "mozilla.org", whose path contains a component "b" somewhere in the middle.</p> + </td> + <td> + <p><code>https://mozilla.org/a/b/c/</code></p> + + <p><code>https://mozilla.org/d/b/f/</code></p> + + <p><code>https://mozilla.org/a/b/c/d/</code></p> + </td> + <td> + <p><code>https://mozilla.org/b/*/</code><br> + (unmatched path)</p> + + <p><code>https://mozilla.org/a/b/</code><br> + (unmatched path)</p> + </td> + </tr> + <tr> + <td> + <p><code>file:///blah/*</code></p> + + <p>Match any FILE URL whose path begins with "blah".</p> + </td> + <td> + <p><code>file:///blah/</code></p> + + <p><code>file:///blah/bleh</code></p> + </td> + <td><code>file:///bleh/</code><br> + (unmatched path)</td> + </tr> + </tbody> +</table> + +<h3 id="Invalid_match_patterns">Invalid match patterns</h3> + +<table class="fullwidth-table standard-table"> + <thead> + <tr> + <th scope="col">Invalid pattern</th> + <th scope="col">Reason</th> + </tr> + </thead> + <tbody> + <tr> + <td><code>resource://path/</code></td> + <td>Unsupported scheme.</td> + </tr> + <tr> + <td><code>https://mozilla.org</code></td> + <td>No path.</td> + </tr> + <tr> + <td><code>https://mozilla.*.org/</code></td> + <td>"*" in host must be at the start.</td> + </tr> + <tr> + <td><code>https://*zilla.org/</code></td> + <td>"*" in host must be the only character or be followed by ".".</td> + </tr> + <tr> + <td><code>http*://mozilla.org/</code></td> + <td>"*" in scheme must be the only character.</td> + </tr> + <tr> + <td><code>file://*</code></td> + <td>Empty path: this should be "<code>file:///*</code>".</td> + </tr> + </tbody> +</table> + +<h2 id="Testing_match_patterns">Testing match patterns</h2> + +<p>When writing extensions, you don't generally work with match patterns directly: usually you pass a match pattern string into an API, and the API constructs a match pattern and uses it to test URLs. However, if you're trying to work out which match pattern to use, or debugging a problem with one, it can be useful to be able to create and test match patterns directly. This section explains how to do this.</p> + +<p>Note that the code here <strong>will not work</strong> in an extension, and is only provided to help manually test match patterns using the console.</p> + +<p>First, open the developer tool settings and check the setting marked "Enable browser chrome and add-on debugging toolboxes":</p> + +<p>{{EmbedYouTube("JDEe2fyFpHE")}}</p> + +<p>Next, open the "Browser Console":</p> + +<p>{{EmbedYouTube("mfuBMje6dA4")}}</p> + +<p>This gives you a command line that you can use to execute privileged JavaScript in Firefox.</p> + +<div class="warning"> +<p>Because code running in the Browser Console has system privileges, any time you use it to run code, you need to understand exactly what the code is doing. That includes the code samples in this article.</p> +</div> + +<p>Now paste this code into the command line and press <kbd>enter</kbd>:</p> + +<pre class="brush: js">Cu.import("resource://gre/modules/MatchPattern.jsm"); +Cu.import("resource://gre/modules/BrowserUtils.jsm");</pre> + +<p>This does two things:</p> + +<ul> + <li>imports "MatchPattern.jsm": this is the system module that implements match patterns. Specifically, the module contains a constructor for <code>MatchPattern</code> objects. <code>MatchPattern</code> objects define a function called <code>matches()</code>, that takes a URI and returns <code>true</code> or <code>false</code>.</li> + <li>imports "BrowserUtils.jsm": this includes a function <code>makeURI()</code>, that converts a string into an <code><a href="/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIURI">nsIURI</a></code> object. <code>nsIURI</code> is the type that <code>matches()</code> expects to receive.</li> +</ul> + +<p>Now you can construct <code>MatchPattern</code> objects, construct URIs, and check whether the URIs match:</p> + +<pre class="brush: js">var match = new MatchPattern("*://mozilla.org/"); + +var uri = BrowserUtils.makeURI("https://mozilla.org/"); +match.matches(uri); // < true + +uri = BrowserUtils.makeURI("https://mozilla.org/path"); +match.matches(uri); // < false</pre> + +<h2 id="Converting_Match_Patterns_to_Regular_Expressions">Converting Match Patterns to Regular Expressions</h2> + +<p>All match patterns can be represented by regular expressions. This code converts a match pattern to a regular expression:</p> + +<pre class="brush: js">/** + * Transforms a valid match pattern into a regular expression + * which matches all URLs included by that pattern. + * + * @param {string} pattern The pattern to transform. + * @return {RegExp} The pattern's equivalent as a RegExp. + * @throws {TypeError} If the pattern is not a valid MatchPattern + */ +function matchPatternToRegExp(pattern) { + if (pattern === '') { + return (/^(?:http|https|file|ftp|app):\/\//); + } + + const schemeSegment = '(\\*|http|https|file|ftp)'; + const hostSegment = '(\\*|(?:\\*\\.)?(?:[^/*]+))?'; + const pathSegment = '(.*)'; + const matchPatternRegExp = new RegExp( + `^${schemeSegment}://${hostSegment}/${pathSegment}$` + ); + + let match = matchPatternRegExp.exec(pattern); + if (!match) { + throw new TypeError(`"${pattern}" is not a valid MatchPattern`); + } + + let [, scheme, host, path] = match; + if (!host) { + throw new TypeError(`"${pattern}" does not have a valid host`); + } + + let regex = '^'; + + if (scheme === '*') { + regex += '(http|https)'; + } else { + regex += scheme; + } + + regex += '://'; + + if (host && host === '*') { + regex += '[^/]+?'; + } else if (host) { + if (host.match(/^\*\./)) { + regex += '[^/]*?'; + host = host.substring(2); + } + regex += host.replace(/\./g, '\\.'); + } + + if (path) { + if (path === '*') { + regex += '(/.*)?'; + } else if (path.charAt(0) !== '/') { + regex += '/'; + regex += path.replace(/\./g, '\\.').replace(/\*/g, '.*?'); + regex += '/?'; + } + } + + regex += '$'; + return new RegExp(regex); +} +</pre> diff --git a/files/ar/mozilla/add-ons/webextensions/ما_هي_امتدادات_الويب/index.html b/files/ar/mozilla/add-ons/webextensions/ما_هي_امتدادات_الويب/index.html new file mode 100644 index 0000000000..b407fc48a7 --- /dev/null +++ b/files/ar/mozilla/add-ons/webextensions/ما_هي_امتدادات_الويب/index.html @@ -0,0 +1,56 @@ +--- +title: ما هي الامتدادات؟ +slug: Mozilla/Add-ons/WebExtensions/ما_هي_امتدادات_الويب +translation_of: Mozilla/Add-ons/WebExtensions/What_are_WebExtensions +--- +<div>{{AddonSidebar}}</div> + +<p>An extension adds features and functions to a browser. It’s created using familiar web-based technologies—HTML, CSS, and JavaScript. It can take advantage of the same web APIs as JavaScript on a web page, but an extension also has access to its own set of JavaScript APIs. This means that you can do a lot more in an extension than you can with code in a web page. Here are just a few examples of the things you can do:</p> + +<p><strong>Enhance or complement a website</strong>: Use an add-on to deliver additional in-browser features or information from your website. Allow users to collect details from pages they visit to enhance the service you offer.</p> + +<p><img alt="" src="https://mdn.mozillademos.org/files/15808/Amazon_add_on.png"></p> + +<p>Examples: <a href="https://addons.mozilla.org/en-US/firefox/addon/amazon-browser-bar/">Amazon Assistant for Firefox</a>, <a href="https://addons.mozilla.org/en-US/firefox/addon/onenote-clipper/">OneNote Web Clipper</a>, and <a href="https://addons.mozilla.org/en-US/firefox/addon/grammarly-1/">Grammarly for Firefox</a></p> + +<p><strong>Let users show their personality</strong>: Browser extensions can manipulate the content of web pages; for example, letting users add their favorite logo or picture as a background to every page they visit. Extensions may also enable users to update the look of the Firefox UI, the same way standalone <a href="https://developer.mozilla.org/en-US/Add-ons/Themes/Theme_concepts">theme add-ons</a> do.</p> + +<p><img alt="" src="https://mdn.mozillademos.org/files/15809/MyWeb_New_Tab_add_on.png" style="height: 398px; width: 540px;"></p> + +<p>Examples: <a href="https://addons.mozilla.org/en-US/firefox/addon/myweb-new-tab/">MyWeb New Tab</a>, <a href="https://addons.mozilla.org/en-US/firefox/addon/tabliss/">Tabliss</a>, and <a href="https://addons.mozilla.org/en-US/firefox/addon/vivaldifox/">VivaldiFox</a></p> + +<p><strong>Add or remove content from web pages</strong>: You might want to help users block intrusive ads from web pages, provide access to a travel guide whenever a country or city is mentioned in a web page, or reformat page content to offer a consistent reading experience. With the ability to access and update both a page’s HTML and CSS, extensions can help users see the web the way they want to.</p> + +<p><img alt="" src="https://mdn.mozillademos.org/files/15807/ublock_origin_add_on.png" style="height: 480px; width: 640px;"></p> + +<p>Examples: <a href="https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/">uBlock Origin</a>, <a href="https://addons.mozilla.org/en-US/firefox/addon/reader/">Reader</a>, and <a href="https://addons.mozilla.org/en-US/firefox/addon/toolbox-google-play-store/">Toolbox for Google Play Store™</a></p> + +<p><strong>Add tools and new browsing features</strong>: Add new features to a taskboard, or generate QR code images from URLs, hyperlinks, or page text. With flexible UI options and the power of the <a href="/en-US/Add-ons/WebExtensions">WebExtensions APIs</a> you can easily add new features to a browser. And, you can enhance almost any website’s features or functionality, it doesn't have to be your website.</p> + +<p><img alt="" src="https://mdn.mozillademos.org/files/15806/QR_Code_Image_Generator_add_on.png"></p> + +<p>Examples: <a href="https://addons.mozilla.org/en-US/firefox/addon/swimlanes-for-trello/">Swimlanes for Trello</a> and <a href="https://addons.mozilla.org/en-US/firefox/addon/tomato-clock/">Tomato Clock</a></p> + +<p><strong>Games</strong>: Offer traditional computer games with off-line play features, or explore new game possibilities; for example, by incorporating gameplay into everyday browsing.</p> + +<p> <img alt="" src="https://mdn.mozillademos.org/files/15805/Asteroids_in_Popup_add_on%20.png" style="height: 438px; width: 700px;"></p> + +<p>Examples: <a href="https://addons.mozilla.org/en-US/firefox/addon/asteroids-in-popup/">Asteroids in Popup</a>, <a href="https://addons.mozilla.org/en-US/firefox/addon/solitaire-card-game-new-tab/">Solitaire Card Game New Tab</a>, and <a href="https://addons.mozilla.org/en-US/firefox/addon/2048-prime/">2048 Prime</a>.</p> + +<p><strong>Add development tools</strong>: You may provide web development tools as your business or have developed a useful technique or approach to web development that you want to share. Either way, you can enhance the built-in Firefox developer tools by adding a new tab to the developer toolbar.</p> + +<p><img alt="" src="https://mdn.mozillademos.org/files/15804/aXe_Developer_Tools_add_on.png" style="height: 261px; width: 700px;"></p> + +<p>Examples: <a href="https://addons.mozilla.org/en-US/firefox/addon/web-developer/">Web Developer</a>, <a href="https://addons.mozilla.org/en-US/firefox/addon/react-devtools/">Web React Developer Tools</a>, and <a href="https://addons.mozilla.org/en-US/firefox/addon/axe-devtools/">aXe Developer Tools</a></p> + +<p>Extensions for Firefox are built using the <a href="/en-US/Add-ons/WebExtensions">WebExtensions APIs</a>, a cross-browser system for developing extensions. To a large extent, the API is compatible with the <a class="external external-icon" href="https://developer.chrome.com/extensions">extension API</a> supported by Google Chrome and Opera. Extensions written for these browsers will in most cases run in Firefox or Microsoft Edge with just a few <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Porting_a_Google_Chrome_extension">changes</a>. The API is also fully compatible with <a href="/en-US/Firefox/Multiprocess_Firefox">multiprocess Firefox</a>.</p> + +<p>If you have ideas or questions, or need help migrating a legacy add-on to WebExtensions APIs, you can reach us on the <a class="external external-icon" href="https://mail.mozilla.org/listinfo/dev-addons">dev-addons mailing list</a> or in <a href="irc://irc.mozilla.org/extdev">#addons</a> on <a class="external external-icon" href="https://wiki.mozilla.org/IRC">IRC</a>.</p> + +<h2 id="Whats_next">What's next?</h2> + +<ul> + <li>Walk through the development of a simple extension in <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Your_first_WebExtension">Your first extension</a>.</li> + <li>Learn about the structure of an extension in <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/Anatomy_of_a_WebExtension">Anatomy of an extension</a>.</li> + <li>Try out some example extensions in <a href="/en-US/Add-ons/WebExtensions/Examples">Example extensions</a>.</li> +</ul> |