-
Notifications
You must be signed in to change notification settings - Fork 2
/
background.js
36 lines (32 loc) · 1012 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
25
26
27
28
29
30
31
32
33
34
35
36
var selectedId;
chrome.tabs.onUpdated.addListener(checkForValidUrl); /* when user changes URL of current tab */
chrome.tabs.onActivated.addListener(function(tabId, info) {
selectedId = tabId;
});
chrome.runtime.onMessage.addListener(
function(request,sender,sendResponse) {
if (request.greeting == "entireWork") {
chrome.tabs.executeScript(null, {
file: "OnePage.js"
});
}
else if (request.greeting == "download") {
chrome.tabs.executeScript(null, {
file: "Download.js"
});
}
}
)
function checkForValidUrl(tabId, changeInfo, tab) {
if (tab.url.indexOf('fanfiction') > -1) {
// ... show the page action.
chrome.pageAction.show(tabId); /* if in fanfiction.net/s/, then extension icon is in color */
} else {
chrome.pageAction.hide(tabId);
}
}
function RipStory(tab) {
chrome.tabs.executeScript(null, {
file: "OnePage.js"
});
}