-
Notifications
You must be signed in to change notification settings - Fork 1
/
populate_settings.js
61 lines (53 loc) · 1.85 KB
/
populate_settings.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
function setValueToStorage(key, value) {
// Set into storage
chrome.storage.local.set({ key: '' }, function () {
console.log("The color is green.");
});
}
var getSettingsInfo = function (button) {
let self = {};
self.button = button;
let response = chrome.runtime.sendMessage('{extension: "active", settings_mode: true}', (res) => {
var pfntSiteData = JSON.parse(document.getElementById('pfnt__pfSiteData').value);
console.log('PFNT Setting Prep', pfntSiteData, document);
pfntSiteData.settings_mode = true;
let response = chrome.runtime.sendMessage(pfntSiteData, function (res) {
console.log('PFNT Message Sent');
console.log(res);
});
console.log('response from sendMessage', response);
chrome.storage.local.set(pfntSiteData, () => {
console.log("System variables set for PFNT");
if (self.button) {
console.log('button', self.button);
var button = document.getElementById("pressforward-nt__" + self.button);
button.style.backgroundColor = 'lightgreen';
button.innerHTML = 'API Keys Saved';
}
});
console.log(res);
});
};
console.log('PFNT Settings Population Prep');
console.log('PFNT Settings Population Hooking');
setTimeout(getSettingsInfo, 10000);
console.log('PFNT bind_populate_settings.js');
window.setTimeout(function () {
console.log('PFNT timeout completed, binding');
var setupButton = document.getElementById("pressforward-nt__setup-button")
if (setupButton) {
setupButton.addEventListener("click", (e) => {
//document.addEventListener("click", (e) => {
getSettingsInfo('setup-button');
});
}
var regenButton = document.getElementById("pressforward-nt__regenerate-button")
if (regenButton) {
regenButton.addEventListener("click", (e) => {
//document.addEventListener("click", (e) => {
window.setTimeout(function () {
getSettingsInfo('regenerate-button');
}, 1000);
});
}
}, 1000);