forked from kumorikuma/stepmaniax_shopify_bot_extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
executable file
·40 lines (35 loc) · 1.19 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
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
'use strict';
let isRunning = false;
const runBtn = document.getElementById("runScript");
function updateRunButton(isRunning) {
if (isRunning) {
runBtn.innerHTML = "Whoa stop refreshing!";
} else {
runBtn.innerHTML = "Let's buy this shit!";
}
}
chrome.storage.local.get(['isRunning'], function(result) {
isRunning = result.isRunning;
runBtn.disabled = false;
updateRunButton(isRunning);
});
runBtn.onclick = function(element) {
if (!isRunning) {
isRunning = true;
runBtn.innerHTML = "Whoa stop refreshing!";
chrome.tabs.query({ active: true, currentWindow: true }, function(tabs) {
const activeTabId = tabs[0].id;
chrome.runtime.sendMessage({event: "setActiveTab", tabId: activeTabId});
chrome.tabs.executeScript(activeTabId, {
file: 'addToCart.js'
});
});
} else {
isRunning = false;
runBtn.innerHTML = "Let's buy this shit!";
chrome.runtime.sendMessage({event: "stop"});
}
};