Qiita Conference 2025

ymrl (@ymrl)

がんばらないアクセシビリティ: より幅広く価値を届けるために

12
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Chrome拡張 | 基礎

Posted at

:musical_score: 概要

Chrome 拡張の基礎

Chrome拡張 とは?

HTML, JavaScripot, CSS などによってブラウザの機能を変更・強化する。
Chrome 拡張はユーザーインターフェースをほとんど持たない。

Chrome Web Store に公開するために、 Chrome Developer Dashboard から Chrome 拡張を配布できる。

構成

manifest file

manifest file は JSON 形式のメタデータを記述するファイルです。
ファイル名は manifest.json です。

manifest file の扱う項目

  • version
  • Chrome 拡張の名前
  • Chrome 拡張の説明
  • actions
    • browserAction: アドレスバーの右のメニューアイコンに設定します
    • pageAction: アドレスバーの中にメニューアイコンに設定します
  • permissions
    • tabs: ブラウザのタブシステムへのパーミッションを取得します
    • activeTab: ユーザーが Chrome 拡張を実行した時にアクティブなタブのパーミッションを取得します

サンプル

私が公開している、
qiita ( ˘ω˘)ノ"Y☆Yヾ(˘ω˘ ) twitter
の manifest file です。

{
  "name": "qiita ( ˘ω˘)ノ\"Y☆Yヾ(˘ω˘ ) twitter",
  "version": "1.0.0",
  "manifest_version": 2,
  "description": "You can easily get one's qiita article.",
  "icons": {
    "16": "icons/icon-16.png",
    "48": "icons/icon-48.png",
    "128": "icons/icon-128.png"
  },
  "browser_action": {
    "default_icon": "/icons/icon-48.png"
  },
  "background": {
    "scripts": ["js/jquery-2.1.1.min.js", "js/background.js"]
  },
  "content_scripts": [{
    "matches": ["https://twitter.com/*"],
    "js": ["js/jquery-2.1.1.min.js", "js/contentscript.js"]
  }],
  "permissions": [
    "tabs"
  ]
}

Manifest File の詳細フォーマットについては下記を参照。

Manifest File Format

Load the extension

Extension の読み込み方法について。

chrome://extensions/ を開く

右上にある「デベロッパーモード」のチェックボックスを有効化する

extension1.png

パッケージ化されていない拡張機能を読み込む、を選択する

extension1.png

自作した Chrome 拡張を選択する

※ドラッグ & ドロップも可能

完了

以上で、自作した Chrome 拡張を読み込むことができます

:books: 外部資料

What are extensions?

12
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Qiita Conference 2025 will be held!: 4/23(wed) - 4/25(Fri)

Qiita Conference is the largest tech conference in Qiita!

Keynote Speaker

ymrl、Masanobu Naruse, Takeshi Kano, Junichi Ito, uhyo, Hiroshi Tokumaru, MinoDriven, Minorun, Hiroyuki Sakuraba, tenntenn, drken, konifar

View event details
12
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?