Skip to content

Instantly share code, notes, and snippets.

@oyvindholmstad
Last active August 31, 2015 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oyvindholmstad/6fd339f54829b0569a5d to your computer and use it in GitHub Desktop.
Save oyvindholmstad/6fd339f54829b0569a5d to your computer and use it in GitHub Desktop.
An example of a simple contentscript for a Chrome Extension.
function createToolBar(toolbarUrl, callback) {
var toolbar = $('<div>').attr("id", "oda-toolbar");
$('body').prepend(toolbar);
var url = chrome.extension.getURL(toolbarUrl);
$('#oda-toolbar').load(url, function() { callback();});
}
function setupSearchInput() {
$("input#odaSearch").keyup(function (e) {
if (e.keyCode == 13) {
window.location = tvBaseUrl + "/Program/" + $(event.target).val();
}
});
}
$(document).ready(function() {
var toolbarUrl = "content/toolbar.html";
createToolBar(toolbarUrl, function() {
setupSearchInput();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment