-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
69 lines (52 loc) · 1.74 KB
/
popup.js
File metadata and controls
69 lines (52 loc) · 1.74 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
$(function(){
$('#keywordsubmit').click(function(){
// var search_topic = $('#keyword').val();
// var textNodes = document.querySelectorAll('body, body *:not(script):not(style)');
// var allText = '';
// textNodes.forEach(function(node) {
// allText += node.textContent;
// });
// var allText = '';
chrome.tabs.executeScript(null, {
code: `document.all[0].innerText`,
allFrames: false, // this is the default
runAt: 'document_start', // default is document_idle. See https://stackoverflow.com/q/42509273 for more details.
}, function(results) {
// results.length must be 1
var allText = results[0];
chrome.runtime.sendMessage(
// {topic: search_topic},
{topic: allText},
function(response) {
result = response.farewell;
alert(result.summary);
var notifOptions = {
type: "basic",
// iconUrl: "summary.jpg",
title: "Text Summary For Your Result",
message: result.summary
};
// var notificationId = "WikiNotif" + Data.now();
chrome.notifications.create('WikiNotif', notifOptions);
});
});
// if (search_topic){
// chrome.runtime.sendMessage(
// // {topic: search_topic},
// {topic: allText},
// function(response) {
// result = response.farewell;
// alert(result.summary);
// var notifOptions = {
// type: "basic",
// // iconUrl: "summary.jpg",
// title: "Text Summary For Your Result",
// message: result.summary
// };
// // var notificationId = "WikiNotif" + Data.now();
// chrome.notifications.create('WikiNotif', notifOptions);
// });
// }
// $('#keyword').val('');
});
});