├── icon16.png ├── README.md ├── manifest.json └── background.js /icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/genius/omnibox-example/master/icon16.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | An example Chrome extension for interacting with the [Genius API](http://genius.com/developers). 2 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Genius Search", 3 | "version": "0.0.1", 4 | "manifest_version": 2, 5 | 6 | "omnibox": { 7 | "keyword": "genius" 8 | }, 9 | 10 | "icons": { 11 | "16": "icon16.png" 12 | }, 13 | 14 | "background": { 15 | "scripts": ["background.js"] 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /background.js: -------------------------------------------------------------------------------- 1 | chrome.omnibox.onInputChanged.addListener(function (query, suggest) { 2 | var accessToken = ''; 3 | 4 | fetch('https://api.genius.com/search?access_token=' + accessToken + '&q=' + encodeURIComponent(query)).then(function (response) { 5 | response.json().then(function (data) { 6 | suggest(data.response.hits.map(function (hit) { 7 | return { 8 | content: hit.result.url, 9 | description: hit.result.title + ' by ' + hit.result.primary_artist.name 10 | }; 11 | })); 12 | }); 13 | }); 14 | }); 15 | 16 | chrome.omnibox.onInputEntered.addListener(function (content) { 17 | chrome.tabs.update({ url: content }); 18 | }); 19 | --------------------------------------------------------------------------------