Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (37 sloc) 1.09 KB
<html>
<head>
<script>
// Called when the url of a tab changes.
function checkForValidUrl(tabId, changeInfo, tab) {
if (tab.url.indexOf('http://www.reddit.com/') > -1) {
chrome.pageAction.show(tabId);
}
};
// Listen for any changes to the URL of any tab.
chrome.tabs.onUpdated.addListener(checkForValidUrl);
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
chrome.tabs.create({
"url":request.url,
"selected":request.focus,
"index":sender.tab.index
}, function (tab) {
chrome.tabs.executeScript(tab.id, {
code: "\
var rightPressed = false; \
document.addEventListener('keydown', \
function (event) { \
if (event.keyCode == 39) { \
rightPressed = true; \
} else if (!rightPressed || event.altKey) { \
if(event.keyCode == 37 && (typeof(keysOn) === 'undefined' || \
keysOn === true)) self.close(); \
} \
});"
});
});
}
);
</script>
</head>
</html>