forked from Blogger-Peer-Review/quotebacks
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackground.js
More file actions
105 lines (81 loc) · 2.7 KB
/
background.js
File metadata and controls
105 lines (81 loc) · 2.7 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
chrome.storage.local.get(null, function(items) {
allKeys = Object.keys(items);
});
chrome.commands.onCommand.addListener(function(command) {
//send ping. If no response then load scripts.
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {message: "ping"}, function(response) {
if(response){
// Send copyquote command
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {message: "copyquote"}, function(response) {
});
});
}
else{
chrome.tabs.executeScript({
file: 'webcomponents-sd-ce.js'
});
chrome.tabs.executeScript({
file: 'quoteback-internal.js'
});
chrome.tabs.executeScript({
file: 'quotestyle.js'
});
chrome.tabs.executeScript({
file: 'rangy-core.js'
});
chrome.tabs.executeScript({
file: 'turndown.js'
});
// files for highlighter
/*
chrome.tabs.executeScript({
file: 'rangy-classapplier.js'
});
chrome.tabs.executeScript({
file: 'rangy-highlighter.js'
});
chrome.tabs.insertCSS({
file: 'styles/quoteback-highlighter.css'
});
*/
chrome.tabs.executeScript({
file: 'newcontent.js',
},
function(){
// Send copyquote command
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {message: "copyquote"}, function(response) {
});
});
}
);
}
});
});
});
chrome.browserAction.setPopup({popup:''}); //disable browserAction's popup
// proof of concept that can watch for pages in DB then:
// retrieve serializedhighlights
// send message to page to deserialize highlights
//requires webNavigation permission in manifest.json
/*
chrome.webNavigation.onCompleted.addListener(function(e) {
if (allKeys.includes(e.url)){
console.log("page in DB");
}
});
*/
chrome.browserAction.onClicked.addListener(()=>{
chrome.tabs.create({url:'options.html'});
});
// Check whether new version is installed
chrome.runtime.onInstalled.addListener(function(details){
if(details.reason == "install"){
chrome.tabs.create({url:'https://quotebacks.net/welcome.html'});
}else if(details.reason == "update"){
var thisVersion = chrome.runtime.getManifest().version;
console.log("Updated from " + details.previousVersion + " to " + thisVersion + "!");
}
});