-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
47 lines (37 loc) · 1.64 KB
/
popup.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
37
38
39
40
41
42
43
44
45
46
47
document.addEventListener('DOMContentLoaded', function() {
const textArea = document.getElementById('feeds');
chrome.storage.local.get(['feed'], function(result) {
if(result.feed){
textArea.value = result.feed;
}
});
const fillButtton = document.getElementById('fillButton');
fillButtton.addEventListener('click' , ()=>{
chrome.storage.local.set({"feed": textArea.value}, function() {
chrome.tabs.getSelected(null, function(tab) {
if (tab && tab.status == "complete") {
chrome.tabs.executeScript(tab.id, { file: "jquery.js" }, function() {
chrome.tabs.executeScript(tab.id, { code: "var right_clicked = false;" }, function() {
chrome.tabs.executeScript(tab.id, { file: "script.js" });
window.close();
});
});
}
})
});
})
document.getElementById('clearButton').addEventListener("click" , ()=>{
textArea.value = ''
chrome.storage.local.set({"feed": ''}, function() { });
})
chrome.browserAction.onClicked.addListener(function(tab) {
console.log("tab is in popup");
if (tab && tab.status == "complete") {
chrome.tabs.executeScript(tab.id, { file: "jquery.js" }, function() {
chrome.tabs.executeScript(tab.id, { code: "var right_clicked = false;" }, function() {
chrome.tabs.executeScript(tab.id, { file: "script.js" });
});
});
}
})
}, false);