Reputation: 15599
Can I run small script snippets in Chrome all the time, as they were mini extensions? Without the manifest and packaging involved with a regular extension?
I basically want to "hack" Chrome to send events when I press media keys. A script like so:
sendRequest = function(action) {
return chrome.extension.sendRequest({
action: action
}, (function() {}));
};
document.addEventListener("keydown", function(e) {
if (e.keyCode === 32) {
return sendRequest("pause");
} else if (e.keyCode === 37) {
return sendRequest("previous");
} else if (e.keyCode === 39) {
return sendRequest("next");
}
});
I'm imagining this can be added via the Sources tab and some of the new magic there, but not sure.
Upvotes: 0
Views: 46
Reputation: 32286
The extensions API (chrome.extension.sendRequest
) is not available to non-extensions, obviously. A real mini-extension should do the job.
Upvotes: 2