Chrome Extensions2013. 5. 10. 23:33

크롬의 주소 표시 줄에 키워드를 등록.

사용자가 키워들을 입력하면, 사용자와 상호작용.


예.

사용자가 등록한 키워드를 입력합니다.



클릭하면 그에 맞게 응답을 합니다.


Manifest.json

{
  "name": "Omnibox TEST",
  "description" : "url = 'omnix'",
  "version": "1",
  "background": {
    "scripts": ["background.js"]
  },

  // omnibox 발생 키워드
  "omnibox": { "keyword" : "omnix" },
  "manifest_version": 2
}


background.js

// 매니페스트에 설정한 키워드 URL 입력시 이벤트
chrome.omnibox.onInputChanged.addListener(
  function(text, suggest) {
    console.log('inputChanged:' + text);
    suggest([
      {content: text + " ONE", description: "ONE LINE."},
      {content: text + " TWO", description: "TWO LINE."}
    ]);
  });

// omnibox를 선택시 이벤트
chrome.omnibox.onInputEntered.addListener(
  function(text) {
    console.log('inputEntered: ' + text);
    alert('alert : "' + text + '"');
  });


chrome.omnibox reference


'Chrome Extensions' 카테고리의 다른 글

[Browser UI]Override Pages  (0) 2013.05.12
[Browser UI]Options Pages  (0) 2013.05.11
[Browser UI]Desktop Notifications  (0) 2013.05.10
[Browser UI]contextMenus  (0) 2013.05.10
[Browser UI]browserAction  (0) 2013.05.09
Posted by 건깡