Switched it from using local storage to synced storage.

This commit is contained in:
Ajay Ramachandran
2019-07-22 16:42:57 -04:00
parent 14121af900
commit baefc59954
3 changed files with 18 additions and 18 deletions

View File

@@ -53,7 +53,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
function getSponsorTimes(videoID, callback) { function getSponsorTimes(videoID, callback) {
let sponsorTimes = []; let sponsorTimes = [];
let sponsorTimeKey = "sponsorTimes" + videoID; let sponsorTimeKey = "sponsorTimes" + videoID;
chrome.storage.local.get([sponsorTimeKey], function(result) { chrome.storage.sync.get([sponsorTimeKey], function(result) {
let sponsorTimesStorage = result[sponsorTimeKey]; let sponsorTimesStorage = result[sponsorTimeKey];
if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) { if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) {
sponsorTimes = sponsorTimesStorage; sponsorTimes = sponsorTimesStorage;
@@ -79,7 +79,7 @@ function addSponsorTime(time) {
//save this info //save this info
let sponsorTimeKey = "sponsorTimes" + previousVideoID; let sponsorTimeKey = "sponsorTimes" + previousVideoID;
chrome.storage.local.set({[sponsorTimeKey]: sponsorTimes}); chrome.storage.sync.set({[sponsorTimeKey]: sponsorTimes});
}); });
} }
@@ -109,7 +109,7 @@ 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.local.get([sponsorTimeKey], function(result) { chrome.storage.sync.get([sponsorTimeKey], function(result) {
let sponsorTimes = result[sponsorTimeKey]; let sponsorTimes = result[sponsorTimeKey];
if (sponsorTimes != undefined && sponsorTimes.length > 0) { if (sponsorTimes != undefined && sponsorTimes.length > 0) {
@@ -140,7 +140,7 @@ function videoIDChange(currentVideoID) {
if (previousVideoID != null) { if (previousVideoID != null) {
//get the sponsor times from storage //get the sponsor times from storage
let sponsorTimeKey = 'sponsorTimes' + previousVideoID; let sponsorTimeKey = 'sponsorTimes' + previousVideoID;
chrome.storage.local.get([sponsorTimeKey], function(result) { chrome.storage.sync.get([sponsorTimeKey], function(result) {
let sponsorTimes = result[sponsorTimeKey]; let sponsorTimes = result[sponsorTimeKey];
if (sponsorTimes != undefined && sponsorTimes.length > 0) { if (sponsorTimes != undefined && sponsorTimes.length > 0) {
@@ -168,7 +168,7 @@ function getUserID(callback) {
} }
//if it is not cached yet, grab it from storage //if it is not cached yet, grab it from storage
chrome.storage.local.get(["userID"], function(result) { chrome.storage.sync.get(["userID"], function(result) {
let userIDStorage = result.userID; let userIDStorage = result.userID;
if (userIDStorage != undefined) { if (userIDStorage != undefined) {
userID = userIDStorage; userID = userIDStorage;
@@ -178,7 +178,7 @@ function getUserID(callback) {
userID = generateUUID(); userID = generateUUID();
//save this UUID //save this UUID
chrome.storage.local.set({"userID": userID}); chrome.storage.sync.set({"userID": userID});
callback(userID); callback(userID);
} }

View File

@@ -36,7 +36,7 @@ var hideVideoPlayerControls = false;
//if the notice should not be shown //if the notice should not be shown
//happens when the user click's the "Don't show notice again" button //happens when the user click's the "Don't show notice again" button
var dontShowNotice = false; var dontShowNotice = false;
chrome.storage.local.get(["dontShowNoticeAgain"], function(result) { chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) {
let dontShowNoticeAgain = result.dontShowNoticeAgain; let dontShowNoticeAgain = result.dontShowNoticeAgain;
if (dontShowNoticeAgain != undefined) { if (dontShowNoticeAgain != undefined) {
dontShowNotice = dontShowNoticeAgain; dontShowNotice = dontShowNoticeAgain;
@@ -106,7 +106,7 @@ function videoIDChange(id) {
}); });
//see if video control buttons should be added //see if video control buttons should be added
chrome.storage.local.get(["hideVideoPlayerControls"], function(result) { chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) {
if (result.hideVideoPlayerControls != undefined) { if (result.hideVideoPlayerControls != undefined) {
hideVideoPlayerControls = result.hideVideoPlayerControls; hideVideoPlayerControls = result.hideVideoPlayerControls;
} }
@@ -495,7 +495,7 @@ function closeAllSkipNotices(){
} }
function dontShowNoticeAgain() { function dontShowNoticeAgain() {
chrome.storage.local.set({"dontShowNoticeAgain": true}); chrome.storage.sync.set({"dontShowNoticeAgain": true});
dontShowNotice = true; dontShowNotice = true;
@@ -540,7 +540,7 @@ function submitSponsorTimes() {
//clear the sponsor times //clear the sponsor times
let sponsorTimeKey = "sponsorTimes" + currentVideoID; let sponsorTimeKey = "sponsorTimes" + currentVideoID;
chrome.storage.local.set({[sponsorTimeKey]: []}); chrome.storage.sync.set({[sponsorTimeKey]: []});
} else { } else {
//for a more detailed error message, they should check the popup //for a more detailed error message, they should check the popup
//show that the upload failed //show that the upload failed

View File

@@ -22,7 +22,7 @@ var isYouTubeTab = false;
//if the don't show notice again variable is true, an option to //if the don't show notice again variable is true, an option to
// disable should be available // disable should be available
chrome.storage.local.get(["dontShowNoticeAgain"], function(result) { chrome.storage.sync.get(["dontShowNoticeAgain"], function(result) {
let dontShowNoticeAgain = result.dontShowNoticeAgain; let dontShowNoticeAgain = result.dontShowNoticeAgain;
if (dontShowNoticeAgain != undefined && dontShowNoticeAgain) { if (dontShowNoticeAgain != undefined && dontShowNoticeAgain) {
document.getElementById("showNoticeAgain").style.display = "unset"; document.getElementById("showNoticeAgain").style.display = "unset";
@@ -30,7 +30,7 @@ chrome.storage.local.get(["dontShowNoticeAgain"], function(result) {
}); });
//show proper video player controls option //show proper video player controls option
chrome.storage.local.get(["hideVideoPlayerControls"], function(result) { chrome.storage.sync.get(["hideVideoPlayerControls"], function(result) {
let hideVideoPlayerControls = result.hideVideoPlayerControls; let hideVideoPlayerControls = result.hideVideoPlayerControls;
if (hideVideoPlayerControls != undefined && hideVideoPlayerControls) { if (hideVideoPlayerControls != undefined && hideVideoPlayerControls) {
document.getElementById("hideVideoPlayerControls").style.display = "none"; document.getElementById("hideVideoPlayerControls").style.display = "none";
@@ -55,7 +55,7 @@ function loadTabData(tabs) {
//load video times for this video //load video times for this video
let sponsorTimeKey = "sponsorTimes" + currentVideoID; let sponsorTimeKey = "sponsorTimes" + currentVideoID;
chrome.storage.local.get([sponsorTimeKey], function(result) { chrome.storage.sync.get([sponsorTimeKey], function(result) {
let sponsorTimesStorage = result[sponsorTimeKey]; let sponsorTimesStorage = result[sponsorTimeKey];
if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) { if (sponsorTimesStorage != undefined && sponsorTimesStorage.length > 0) {
if (sponsorTimesStorage[sponsorTimesStorage.length - 1] != undefined && sponsorTimesStorage[sponsorTimesStorage.length - 1].length < 2) { if (sponsorTimesStorage[sponsorTimesStorage.length - 1] != undefined && sponsorTimesStorage[sponsorTimesStorage.length - 1].length < 2) {
@@ -140,7 +140,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, callback) {
sponsorTimes[sponsorTimesIndex][startTimeChosen ? 1 : 0] = request.time; sponsorTimes[sponsorTimesIndex][startTimeChosen ? 1 : 0] = request.time;
let sponsorTimeKey = "sponsorTimes" + currentVideoID; let sponsorTimeKey = "sponsorTimes" + currentVideoID;
chrome.storage.local.set({[sponsorTimeKey]: sponsorTimes}); chrome.storage.sync.set({[sponsorTimeKey]: sponsorTimes});
updateStartTimeChosen(); updateStartTimeChosen();
@@ -260,7 +260,7 @@ function clearTimes() {
sponsorTimes = []; sponsorTimes = [];
let sponsorTimeKey = "sponsorTimes" + currentVideoID; let sponsorTimeKey = "sponsorTimes" + currentVideoID;
chrome.storage.local.set({[sponsorTimeKey]: sponsorTimes}); chrome.storage.sync.set({[sponsorTimeKey]: sponsorTimes});
displaySponsorTimes(); displaySponsorTimes();
@@ -305,7 +305,7 @@ function submitTimes() {
} }
function showNoticeAgain() { function showNoticeAgain() {
chrome.storage.local.set({"dontShowNoticeAgain": false}); chrome.storage.sync.set({"dontShowNoticeAgain": false});
chrome.tabs.query({ chrome.tabs.query({
active: true, active: true,
@@ -320,7 +320,7 @@ function showNoticeAgain() {
} }
function hideVideoPlayerControls() { function hideVideoPlayerControls() {
chrome.storage.local.set({"hideVideoPlayerControls": true}); chrome.storage.sync.set({"hideVideoPlayerControls": true});
chrome.tabs.query({ chrome.tabs.query({
active: true, active: true,
@@ -337,7 +337,7 @@ function hideVideoPlayerControls() {
} }
function showVideoPlayerControls() { function showVideoPlayerControls() {
chrome.storage.local.set({"hideVideoPlayerControls": false}); chrome.storage.sync.set({"hideVideoPlayerControls": false});
chrome.tabs.query({ chrome.tabs.query({
active: true, active: true,