ส่วนขยาย 'Hello World' แรกของคุณ
สร้างส่วนขยาย 'Hello World' แบบพื้นฐาน โดยครอบคลุมไฟล์แม니เฟสต์ โครงสร้างพื้นฐาน และการโหลดเข้าสู่เบราว์เซอร์
ส่วนขยาย 'Hello World' แรกของคุณ เป็นบทเรียน Browser Extensions Development (Chrome & Edge) ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Browser Extensions Development (Chrome & Edge) และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Browser Extensions Development (Chrome & Edge) มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Your First Extension: Hello World
Time to build your first extension — a classic Hello World popup that greets you when you click its toolbar icon. The core Manifest V3 shape.
Core Extension Components
Every extension needs a few key files: manifest.json (the blueprint), popup.html (the popup content), and an icon. We'll build them step by step.
Manifest.json: The Blueprint
The manifest.json is the most important file — JSON metadata like name, version, and permissions, in the structure Manifest V3 expects.
Essential Manifest Fields
Start your manifest with three required fields: manifest_version 3, a name, and a version. The snippet below shows the minimal shape.
{ "manifest_version": 3,
"name": "Hello World Extension",
"version": "1.0"
}Adding Description & Icons
Add a description and an icons map so users understand and recognize your extension. Provide several sizes like 16, 48, and 128 pixels.
{ "manifest_version": 3,
"name": "Hello World Extension",
"version": "1.0",
"description": "A simple 'Hello World' extension for CoddyKit.",
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
}
}Defining the Popup with 'action'
The action field defines the toolbar button: default_popup points to your popup HTML, and default_icon sets the toolbar image.
{ "manifest_version": 3,
"name": "Hello World Extension",
"version": "1.0",
"description": "A simple 'Hello World' extension for CoddyKit.",
"icons": { "16": "icon16.png" },
"action": {
"default_popup": "popup.html",
"default_icon": { "16": "icon16.png" }
}
}Creating popup.html
Create popup.html — a plain HTML file holding your Hello World message. Keep it small and light, since it shows in a tiny popup window.
<!DOCTYPE html>
<html>
<head>
<title>Hello World Popup</title>
<style>
body { font-family: sans-serif; padding: 15px; width: 150px; }
h1 { font-size: 1.2em; color: #333; margin: 0; }
</style>
</head>
<body>
<h1>Hello, CoddyKit!</h1>
</body>
</html>Your Extension's Folder Structure
Your folder should now hold manifest.json, popup.html, and the icons, all directly inside — a clean layout the browser can load correctly.
Loading Your Extension (Chrome)
Load it in Chrome or Edge: open chrome://extensions, flip on Developer mode, click Load unpacked, and pick your folder. It joins the list!
Test Your New Extension!
Spot your extension's icon in the toolbar and click it — a popup appears reading "Hello, CoddyKit!" from your popup.html. First extension done!
Quick Check: Manifest V3
Which field is absolutely essential to declare the manifest format version in manifest.json for a Manifest V3 extension?
Recap: Your First Extension
You built and loaded a real extension: a manifest with key fields, an action popup, a popup.html, all run via Developer mode. Keep tinkering!
เรียนรู้ JavaScript ด้วย AI tutor — ฟรี
เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป
- คอร์ส
- 12
- บทเรียน
- 48
คำถามที่พบบ่อย
บทเรียน “ส่วนขยาย 'Hello World' แรกของคุณ” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ส่วนขยาย 'Hello World' แรกของคุณ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Browser Extensions Development (Chrome & Edge) ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Browser Extensions Development (Chrome & Edge) มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ส่วนขยาย 'Hello World' แรกของคุณ”
สร้างส่วนขยาย 'Hello World' แบบพื้นฐาน โดยครอบคลุมไฟล์แม니เฟสต์ โครงสร้างพื้นฐาน และการโหลดเข้าสู่เบราว์เซอร์ คุณปฏิบัติ Browser Extensions Development (Chrome & Edge) ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Browser Extensions Development (Chrome & Edge) หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Browser Extensions Development (Chrome & Edge) บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “ส่วนขยาย 'Hello World' แรกของคุณ” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Browser Extensions Development (Chrome & Edge) นี้ได้ไหม
ได้ บทเรียน Browser Extensions Development (Chrome & Edge) ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- ส่วนขยายเบราว์เซอร์คืออะไร
- การตั้งค่าสภาพแวดล้อมการพัฒนา
- ส่วนขยาย 'Hello World' แรกของคุณ
- กายวิภาคของโครงการส่วนขยาย