-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkong.js
35 lines (27 loc) · 1.04 KB
/
kong.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
document.addEventListener('DOMContentLoaded', function () {
chrome.tabs.query({active: true, currentWindow: true}).then(([tab]) => {
chrome.scripting.executeScript(
{
target: {tabId: tab.id},
files: ['content.js'],
});
});
document.getElementById('msg_btn').addEventListener("click", fireClick,false);
document.getElementById('clr_btn').addEventListener("click", fireClick,false);
}, false);
function fireClick(evt){
if(evt.currentTarget.id === 'clr_btn'){
chrome.tabs.query({ active: true, currentWindow: true}, function(activeTabs) {
chrome.tabs.sendMessage(activeTabs[0].id, { action: 'clear'});
});
return;
}
var msg = document.getElementById('message').value;
if(msg.trim()===''){
alert("Input can not be empty!");
return;
}
chrome.tabs.query({ active: true, currentWindow: true}, function(activeTabs) {
chrome.tabs.sendMessage(activeTabs[0].id, { action: 'display',message:msg.toUpperCase() });
});
}