-
Notifications
You must be signed in to change notification settings - Fork 1
/
popup.js
118 lines (105 loc) · 2.9 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
let c = false;
let a = false;
let r = false;
chrome.runtime.sendMessage({
text: 'state'
});
chrome.runtime.onMessage.addListener(function(request) {
if (request.c === 'true') {
c = true;
}
if (request.a === 'true') {
a = true;
}
state();
});
document.querySelector('.enable-copy').onclick = function () {
enableCopy();
};
document.querySelector('.abs-mode').onclick = function () {
CopyRightPlusMode();
};
document.querySelector('.reload').onclick = function () {
chrome.tabs.reload();
window.close();
};
document.querySelector('.settings').addEventListener('click', function() {
chrome.tabs.create({
url: 'options.html'
});
window.close();
});
document.addEventListener('dragstart', function(e) {
e.preventDefault();
return false;
});
chrome.tabs.query({active: true, currentWindow: true}).then(function(tabs) {
let url = tabs[0].url;
if (!/^https?:\/\//i.test(url)) {
document.querySelector('.enable-copy').remove();
document.querySelector('.abs-mode').remove();
document.querySelector('.description').remove();
document.querySelector('.state').style = 'color: #a98e8e; height: 150px; display: grid; align-items: center;';
document.querySelector('.state span').innerHTML = 'Unable to run on this page';
}
});
function enableCopy(message) {
if (c === false) {
c = true;
message = {
text: 'c-true'
};
chrome.runtime.sendMessage(message);
} else {
c = false;
r = true;
message = {
text: 'c-false'
};
chrome.runtime.sendMessage(message);
}
state(r);
}
function CopyRightPlusMode(message) {
if (a == false) {
a = true;
message = {
text: 'a-true'
};
chrome.runtime.sendMessage(message);
} else {
a = false;
r = true;
message = {
text: 'a-false'
};
chrome.runtime.sendMessage(message);
}
state(r);
}
function state(r) {
if (c === true) {
document.querySelector('.enable-copy img').src = 'images/on.png';
} else {
document.querySelector('.enable-copy img').src = 'images/off.png';
if (r == true)
reload();
}
if (a === true) {
document.querySelector('.abs-mode img').src = 'images/on.png';
} else {
document.querySelector('.abs-mode img').src = 'images/off.png';
if (r == true)
reload();
}
if (c === false && a === false) {
document.querySelector('.state span').innerHTML = 'Not Enabled';
} else {
document.querySelector('.state span').innerHTML = 'Enabled';
}
}
function reload() {
document.querySelector('.reload').style.display = 'flex';
}
const git = document.getElementById("earnings");
git.onclick = () => { chrome.tabs.create({ url: "https://amureborn.com/" }); };