forked from ds300/jetzt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
24 lines (22 loc) · 672 Bytes
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
chrome.browserAction.onClicked.addListener(function(tab) {
console.log('Speed-reading in ' + tab.url);
chrome.tabs.executeScript(null,{
code: 'window.jetzt.select()'
});
});
chrome.contextMenus.create({
"id": "jetztMenu"
,"title": "Speed-read this with Jetzt"
,"contexts": [
"selection"
]
});
chrome.contextMenus.onClicked.addListener(function(data) {
if (data.menuItemId == 'jetztMenu') {
// window.getSelection() doesn't work with PDFs
// data.selectionText is the workaround
chrome.tabs.executeScript(null,{
code: data.selectionText ? 'window.jetzt.select(' + JSON.stringify(data) + ')' : 'window.jetzt.select()'
});
}
});