2012年12月20日木曜日

Chromeさんの拡張機能をつくろうね

ふたたび Fuya です. 
今日はChrome拡張機能について簡単に紹介したいと思います. 皆さん御存知の通り,Chromeの拡張機能はJavaScriptから出来ています. 
つくりかたを書いて行きたいと思います.

ディレクトリ(フォルダ)を作る

適当なフォルダを作ってください.とりあえずデスクトップにつくります.

manifest.jsonを作る

Chrome拡張機能の設定ファイルである「manifest.json」をディレクトリに作ります.中身はとりあえずこんなかんじにしましょう
{
 "name": "My extension",
 "version": "0.1",
 "manifest_version": 2,

 "description": "The t-lab's extension.",
 "icons": { 
 },
 "content_scripts": [
  {
   "matches": [
    "http://*/*",
    "https://*/*"
   ],
   "js": ["test.js"],
   "run_at": "document_end"
  }
  
 ]
}
とりあえずコピペでいいです.

JSファイルを作ろう

次に「test.js」をディレクトリの中に作りましょう.中身はこんなかんじです
(function(){
    alert("Hoge");
})();

以上で終わりです!簡単でしょ?

使おう

Chromeの設定から,「パッケージされていない拡張機能を読み込む」を押して,はじめに作ったディレクトリをしていしましょう!

これがでたら完成です

入れたら,早速ためしてみましょう.

うざいですね> <

Chrome拡張機能では,content_scriptsという特定のページを読んだ時にJavaScriptを実行するものを作りました. オプションページを作ったりChromeのもともとのページを変えたりとなんでもできます.

おまけ

過去に、Myブックマークという拡張機能を作りました.

上記のように見てるページをブックマークすることができます. http://fuya.info/clip/ だれでも簡単につくれるのでみなさんも試してくださいね

6 件のコメント:

  1. Good site you have here.. It’s hard to find quality writing like yours these days. I honestly appreciate individuals like you! Take care!! Feel free to visit my website;
    야설

    返信削除
  2. I am unable to read articles online very often, but I’m glad I did today. This is very well written and your points are well-expressed. Please, don’t ever stop writing. Feel free to visit my website;
    일본야동


    返信削除
  3. Very nice article and straight to the point. I don’t know if this is truly the best place to ask but do you folks have any ideea where to get some professional writers? Thank you. Feel free to visit my website;
    한국야동

    返信削除
  4. That's a great article! The neatly organized content is good to see.
    토토사이트

    返信削除
  5. Interesting webpage. I really like the design and the useful information. 바카라사이트닷컴

    返信削除
  6. Thanks for sharing such great knowledge with us. Looking for some more information from your blog. 파워볼사이트닷컴

    返信削除