-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
87 lines (66 loc) · 2.34 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
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
const msg = document.querySelector('.msg');
var changeButton1 = document.getElementById("pet-change1");
var changeButton2 = document.getElementById("pet-change2");
var changeButton3 = document.getElementById("pet-change3");
var changeButton4 = document.getElementById("pet-change4");
var changeButton5 = document.getElementById("pet-change5");
changeButton1.addEventListener('click', onChange1);
changeButton2.addEventListener('click', onChange2);
changeButton3.addEventListener('click', onChange3);
changeButton4.addEventListener('click', onChange4);
changeButton5.addEventListener('click', onChange5);
const changeSubmit = document.getElementById("pet-submit");
var petName = "Jiejie";
function newMsg(chineseName, image){
var newContent = `<h3 id="pet-name"> ${chineseName} </h3>` +
`<p>`+
`<img height="100" style="max-width: 120px;background-position: top left;" src=${image} />`+
`</p>`;
return newContent;
}
function onChange1(e) {
e.preventDefault();
petName = "Flandre";
chineseName = "Flandre";
let image = "/images/" + petName + "Pet128.png";
let newContent = newMsg(chineseName,image);
msg.innerHTML = newContent;
}
function onChange2(e) {
e.preventDefault();
petName = "Jiejie";
chineseName = "Jiejie";
let image = "/images/" + petName + "Pet128.png";
let newContent = newMsg(chineseName,image);
msg.innerHTML = newContent;
}
function onChange3(e) {
e.preventDefault();
petName = "Scout";
chineseName = "Scout";
let image = "/images/" + petName + "Pet128.png";
let newContent = newMsg(chineseName,image);
msg.innerHTML = newContent;
}
function onChange4(e) {
e.preventDefault();
petName = "Viper";
chineseName = "Viper";
let image = "/images/" + petName + "Pet128.png";
let newContent = newMsg(chineseName,image);
msg.innerHTML = newContent;
}
function onChange5(e) {
e.preventDefault();
petName = "Meiko";
chineseName = "Meiko";
let image = "/images/" + petName + "Pet128.png";
let newContent = newMsg(chineseName,image);
msg.innerHTML = newContent;
}
changeSubmit.onclick= function(e) {
e.preventDefault();
chrome.tabs.query({active: true, currentWindow: true},function(tabs) {
chrome.tabs.sendMessage(tabs[0].id, {getName: petName});
});
}