Fixed background not using serverAddress from config.

This commit is contained in:
Ajay Ramachandran
2019-08-11 17:09:04 -04:00
parent 699ca91a94
commit d42377a5cd

View File

@@ -82,7 +82,6 @@ chrome.runtime.onInstalled.addListener(function (object) {
//save this UUID
chrome.storage.sync.set({
"userID": newUserID,
"serverAddress": serverAddress,
//the last video id loaded, to make sure it is a video id change
"sponsorVideoID": null,
"previousVideoID": null
@@ -126,12 +125,11 @@ function addSponsorTime(time, videoID, callback) {
}
function submitVote(type, UUID, callback) {
chrome.storage.sync.get(["serverAddress", "userID"], function(result) {
const serverAddress = result.serverAddress;
const userID = result.userID;
chrome.storage.sync.get(["userID"], function(result) {
let userID = result.userID;
//publish this vote
sendRequestToServer("GET", serverAddress + "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, function(xmlhttp, error) {
sendRequestToServer("GET", "/api/voteOnSponsorTime?UUID=" + UUID + "&userID=" + userID + "&type=" + type, function(xmlhttp, error) {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
callback({
successType: 1
@@ -156,16 +154,15 @@ function submitVote(type, UUID, callback) {
function submitTimes(videoID, callback) {
//get the video times from storage
let sponsorTimeKey = 'sponsorTimes' + videoID;
chrome.storage.sync.get([sponsorTimeKey, "serverAddress"], function(result) {
chrome.storage.sync.get([sponsorTimeKey], function(result) {
let sponsorTimes = result[sponsorTimeKey];
const serverAddress = result.serverAddress;
const userID = result.userID;
let userID = result.userID;
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
//submit these times
for (let i = 0; i < sponsorTimes.length; i++) {
//submit the sponsorTime
sendRequestToServer("GET", serverAddress + "/api/postVideoSponsorTimes?videoID=" + videoID + "&startTime=" + sponsorTimes[i][0] + "&endTime=" + sponsorTimes[i][1]
sendRequestToServer("GET", "/api/postVideoSponsorTimes?videoID=" + videoID + "&startTime=" + sponsorTimes[i][0] + "&endTime=" + sponsorTimes[i][1]
+ "&userID=" + userID, function(xmlhttp, error) {
if (xmlhttp.readyState == 4 && !error) {
callback({
@@ -249,7 +246,7 @@ function videoIDChange(currentVideoID, tabId) {
function sendRequestToServer(type, address, callback) {
let xmlhttp = new XMLHttpRequest();
xmlhttp.open(type, address, true);
xmlhttp.open(type, serverAddress + address, true);
if (callback != undefined) {
xmlhttp.onreadystatechange = function () {