mirror of
https://github.com/ajayyy/SponsorBlock.git
synced 2025-12-07 20:17:05 +03:00
Fixed background not using serverAddress from config.
This commit is contained in:
@@ -82,7 +82,6 @@ chrome.runtime.onInstalled.addListener(function (object) {
|
|||||||
//save this UUID
|
//save this UUID
|
||||||
chrome.storage.sync.set({
|
chrome.storage.sync.set({
|
||||||
"userID": newUserID,
|
"userID": newUserID,
|
||||||
"serverAddress": serverAddress,
|
|
||||||
//the last video id loaded, to make sure it is a video id change
|
//the last video id loaded, to make sure it is a video id change
|
||||||
"sponsorVideoID": null,
|
"sponsorVideoID": null,
|
||||||
"previousVideoID": null
|
"previousVideoID": null
|
||||||
@@ -126,12 +125,11 @@ function addSponsorTime(time, videoID, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function submitVote(type, UUID, callback) {
|
function submitVote(type, UUID, callback) {
|
||||||
chrome.storage.sync.get(["serverAddress", "userID"], function(result) {
|
chrome.storage.sync.get(["userID"], function(result) {
|
||||||
const serverAddress = result.serverAddress;
|
let userID = result.userID;
|
||||||
const userID = result.userID;
|
|
||||||
|
|
||||||
//publish this vote
|
//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) {
|
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
|
||||||
callback({
|
callback({
|
||||||
successType: 1
|
successType: 1
|
||||||
@@ -156,16 +154,15 @@ function submitVote(type, UUID, callback) {
|
|||||||
function submitTimes(videoID, callback) {
|
function submitTimes(videoID, callback) {
|
||||||
//get the video times from storage
|
//get the video times from storage
|
||||||
let sponsorTimeKey = 'sponsorTimes' + videoID;
|
let sponsorTimeKey = 'sponsorTimes' + videoID;
|
||||||
chrome.storage.sync.get([sponsorTimeKey, "serverAddress"], function(result) {
|
chrome.storage.sync.get([sponsorTimeKey], function(result) {
|
||||||
let sponsorTimes = result[sponsorTimeKey];
|
let sponsorTimes = result[sponsorTimeKey];
|
||||||
const serverAddress = result.serverAddress;
|
let userID = result.userID;
|
||||||
const userID = result.userID;
|
|
||||||
|
|
||||||
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
if (sponsorTimes != undefined && sponsorTimes.length > 0) {
|
||||||
//submit these times
|
//submit these times
|
||||||
for (let i = 0; i < sponsorTimes.length; i++) {
|
for (let i = 0; i < sponsorTimes.length; i++) {
|
||||||
//submit the sponsorTime
|
//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) {
|
+ "&userID=" + userID, function(xmlhttp, error) {
|
||||||
if (xmlhttp.readyState == 4 && !error) {
|
if (xmlhttp.readyState == 4 && !error) {
|
||||||
callback({
|
callback({
|
||||||
@@ -249,7 +246,7 @@ function videoIDChange(currentVideoID, tabId) {
|
|||||||
function sendRequestToServer(type, address, callback) {
|
function sendRequestToServer(type, address, callback) {
|
||||||
let xmlhttp = new XMLHttpRequest();
|
let xmlhttp = new XMLHttpRequest();
|
||||||
|
|
||||||
xmlhttp.open(type, address, true);
|
xmlhttp.open(type, serverAddress + address, true);
|
||||||
|
|
||||||
if (callback != undefined) {
|
if (callback != undefined) {
|
||||||
xmlhttp.onreadystatechange = function () {
|
xmlhttp.onreadystatechange = function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user