vlff李飞飞 commited on
Commit
83f4493
1 Parent(s): a4bff98
browser_qwen/background.js CHANGED
@@ -14,9 +14,20 @@ function send_data(msg){
14
  },
15
  body: JSON.stringify(msg),
16
  })
17
- .then((response) => response.json())
 
 
18
  .then((data) => {
19
- console.log(data.result);
 
 
 
 
 
 
 
 
 
20
  });
21
  }
22
  });
@@ -39,7 +50,7 @@ chrome.runtime.onMessage.addListener(async (msg, sender) => {
39
  }
40
  if (msg.flag == "open_popup_and_send_url_from_popup"){
41
  if (msg.data) {
42
- chrome.storage.sync.get(['data','access_token'], function(result) {
43
  chrome.storage.sync.set({ data: result.data }, function() {
44
  send_data({ 'url' : msg.data, 'task':'pop_url'});
45
  });
 
14
  },
15
  body: JSON.stringify(msg),
16
  })
17
+ .then((response) => {
18
+ console.log(response.json());
19
+ })
20
  .then((data) => {
21
+ console.log(msg["task"])
22
+ if(msg["task"]=="cache"){
23
+ chrome.notifications.create("cache_url", {
24
+ type: 'basic',
25
+ iconUrl: 'img/popup.png',
26
+ title: 'add page',
27
+ message: 'add page success!'
28
+ });
29
+ }
30
+ console.log(data);
31
  });
32
  }
33
  });
 
50
  }
51
  if (msg.flag == "open_popup_and_send_url_from_popup"){
52
  if (msg.data) {
53
+ chrome.storage.sync.get(['data'], function(result) {
54
  chrome.storage.sync.set({ data: result.data }, function() {
55
  send_data({ 'url' : msg.data, 'task':'pop_url'});
56
  });
browser_qwen/src/popup.js CHANGED
@@ -47,6 +47,12 @@ document.getElementById('set_access_token').addEventListener('click', function()
47
  // save config
48
  chrome.storage.local.set({access_token: access_token}, function() {
49
  console.log('access_token is set to ' + access_token);
 
 
 
 
 
 
50
  // chrome.runtime.sendMessage({ data: access_token , close: true , flag: 'set_access_token'});
51
  document.getElementById('access_token').value = '';
52
  });
 
47
  // save config
48
  chrome.storage.local.set({access_token: access_token}, function() {
49
  console.log('access_token is set to ' + access_token);
50
+ chrome.notifications.create("set_access_token", {
51
+ type: 'basic',
52
+ iconUrl: 'img/popup.png',
53
+ title: 'set access token',
54
+ message: 'set access token success, please reopen this extension!'
55
+ });
56
  // chrome.runtime.sendMessage({ data: access_token , close: true , flag: 'set_access_token'});
57
  document.getElementById('access_token').value = '';
58
  });