From 4b1a9203c547c019fc5398082ae19a3f3d4c3efe Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:15 -0500 Subject: initial commit --- .../your_first_webextension/index.html | 143 +++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 files/bn/mozilla/add-ons/webextensions/your_first_webextension/index.html (limited to 'files/bn/mozilla/add-ons/webextensions/your_first_webextension') diff --git a/files/bn/mozilla/add-ons/webextensions/your_first_webextension/index.html b/files/bn/mozilla/add-ons/webextensions/your_first_webextension/index.html new file mode 100644 index 0000000000..c705ed4493 --- /dev/null +++ b/files/bn/mozilla/add-ons/webextensions/your_first_webextension/index.html @@ -0,0 +1,143 @@ +--- +title: আপনার প্রথম WebExtension +slug: Mozilla/Add-ons/WebExtensions/Your_first_WebExtension +translation_of: Mozilla/Add-ons/WebExtensions/Your_first_WebExtension +--- +

{{AddonSidebar}}

+ +

এই অনুচ্ছেদে ফায়ারফক্সের WebExtension তৈরীর আদ্যপন্ত জানব। এই অ্যাড-অন "mozilla.org" অথবা এর সাবডোমেন থেকে আসা সমস্ত পেজে লাল বর্ডার যোগ করবে।

+ +

এই উদাহরণের সোর্স কোড GitHub-এ দেওয়া আছেঃ

+ +

https://github.com/mdn/webextensions-examples/tree/master/borderify.

+ +

প্রথমে দরকার হবে ফায়ারফক্স ৪৫ অথবা তার পরবর্তী ভার্সন।

+ +

WebExtension লিখা

+ +

নতুন একটি ডিরেক্টরী তৈরী করে সেখানে প্রবেশ করুনঃ

+ +
mkdir borderify
+cd borderify
+ +

manifest.json

+ +

এখন "borderify" ডিরেক্টরীর ভেতরে "manifest.json" নামে নতুন একটি ফাইল তৈরী করুন। তাতে নিম্নলিখিত কোড লিখুনঃ

+ +
{
+
+  "manifest_version": 2,
+  "name": "Borderify",
+  "version": "1.0",
+
+  "description": "Adds a solid red border to all webpages matching mozilla.org.",
+
+  "icons": {
+    "48": "icons/border-48.png"
+  },
+
+  "content_scripts": [
+    {
+      "matches": ["*://*.mozilla.org/*"],
+      "js": ["borderify.js"]
+    }
+  ]
+
+}
+ + + +

কিছু ফায়ারফক্স ভার্সনে একটি অতিরক্ত applications key manifest.json-এ যোগ করা লাগতে পারে।

+ +
"applications": {
+  "gecko": {
+    "id": "borderify@example.com",
+    "strict_min_version": "42.0",
+    "strict_max_version": "50.*",
+    "update_url": "https://example.com/updates.json"
+  }
+}
+ +

সবচেয়ে মজার key হচ্ছ content_scripts. এটা ফায়ারফক্সকে সেই সব ওয়েব পেজে স্ক্রীপট লোড করতে বলবে যাদের URL-এ একটি নির্দিষ্ট প্যাটার্ন আছে।এক্ষেত্রে আমরা ফায়ারফক্সকে "mozilla.org" বা এর সাবডোমেনের সমস্ত HTTP অথবা HTTPS পেজে "borderify.js" নামে স্ক্রীপট লোড করতে বলছি।

+ + + +

icons/border-48.png

+ +

The add-on should have an icon. This will be shown next to the add-on's listing in the Add-ons Manager. Our manifest.json promised that we would have an icon at "icons/border-48.png".

+ +

Create the "icons" directory directly under the "borderify" directory. Save an icon there named "border-48.png".  You could use the one from our example, which is taken from the Google Material Design iconset, and is used under the terms of the Creative Commons Attribution-ShareAlike license.

+ +

If you choose to supply your own icon, It should be 48x48 pixels. You could also supply a 96x96 pixel icon, for high-resolution displays, and if you do this it will be specified as the 96 property of the icons object in manifest.json:

+ +
"icons": {
+  "48": "icons/border-48.png",
+  "96": "icons/border-96.png"
+}
+ +

Alternatively, you could supply an SVG file here, and it will be scaled correctly.

+ + + +

borderify.js

+ +

Finally, create a file called "borderify.js" directly under the "borderify" directory. Give it this content:

+ +
document.body.style.border = "5px solid red";
+ +

This script will be loaded into the pages that match the pattern given in the content_scripts manifest.json key. The script has direct access to the document, just like scripts loaded by the page itself.

+ + + +

Testing it out

+ +

First, double check that you have the right files in the right places:

+ +
borderify/
+    icons/
+        border-48.png
+    borderify.js
+    manifest.json
+ +

Open "about:debugging" in Firefox, click "Load Temporary Add-on" and select any file in your add-on's directory:

+ +

{{EmbedYouTube("cer9EUKegG4")}}

+ +

The add-on will now be installed, and will stay until you restart Firefox.

+ +

Now try visiting a page under "mozilla.org", and you should see the red border round the page:

+ +

{{EmbedYouTube("rxBQl2Z9IBQ")}}

+ +

Try experimenting a bit. Edit the content script to change the color of the border, or do something else to the page content. Save the content script, then reload the add-on's files by clicking the "Reload" button in about:debugging. You can see the changes right away:

+ +

{{EmbedYouTube("NuajE60jfGY")}}

+ + + +

Packaging and publishing

+ +

For other people to use your add-on, you need to package it and submit it to Mozilla for signing. To learn more about that, see "Publishing your WebExtension".

+ +

What's next?

+ +

Now you've got an idea of the process of developing a WebExtension for Firefox, try:

+ + -- cgit v1.2.3-54-g00ecf