forked from manki/blogger-smart-quotes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
background.js
35 lines (32 loc) · 1.21 KB
/
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
var BLOGGER_NEW_UI_EDITOR_URL = /^https?:\/\/(?:www|draft)\.blogger\.com\/blogger\.g\?.*#editor\b/;
var BLOGGER_OLD_UI_EDITOR_URL = /^https?:\/\/(?:www|draft)\.blogger\.com\/post-(?:create|edit)\.g\?/;
var GMAIL_URL = /^https:\/\/mail\.google\.com\//;
var FACEBOOK_URL = /^https:\/\/www\.facebook\.com\//;
var arr = [];
function onTabEvent(tabId) {
chrome.tabs.get(tabId, function(tab) {
if (BLOGGER_NEW_UI_EDITOR_URL.test(tab.url) ||
BLOGGER_OLD_UI_EDITOR_URL.test(tab.url) ||
FACEBOOK_URL.test(tab.url) ||
GMAIL_URL.test(tab.url)) {
chrome.pageAction.show(tab.id);
arr.push(tab.id);
} else {
chrome.pageAction.hide(tab.id);
}
});
}
function onPageActionClick(tab) {
chrome.tabs.executeScript(tab.id, {'file': 'changequotes.js'});
}
chrome.tabs.onUpdated.addListener(onTabEvent);
chrome.tabs.onActiveChanged.addListener(onTabEvent);
chrome.pageAction.onClicked.addListener(onPageActionClick);
chrome.commands.onCommand.addListener(function(command) {
if (command == "punctuate") {
chrome.tabs.getSelected(null, function(tab){
onPageActionClick(tab);
//chrome.tabs.executeScript(tab.id, {'file': 'changequotes.js'});
});
}
});