From 7a041a4cef4815d671993e59d9eb8c8207db3334 Mon Sep 17 00:00:00 2001 From: marinoffDev Date: Thu, 14 Nov 2024 02:07:02 +0200 Subject: [PATCH] switch storage.local instead of storage.sync to avoid storage limits and allow for larger game list libraries --- content/contentScript.js | 6 +++--- manifest.json | 5 +++-- popup/popup.js | 8 ++++---- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/content/contentScript.js b/content/contentScript.js index a79794b..bf1b36a 100644 --- a/content/contentScript.js +++ b/content/contentScript.js @@ -4,7 +4,7 @@ let pointsBudget = 0; // Load the game list from storage and mark added games async function loadGameList() { - const result = await chrome.storage.sync.get(['gameList']); + const result = await chrome.storage.local.get(['gameList']); gameList = result.gameList || []; gameList.forEach(savedGame => { markGiveawayAsAdded(savedGame.id); @@ -67,7 +67,7 @@ function createAddButton(gameId, gameName, gameLink) { // Save updated game list to storage async function saveGameList() { - await chrome.storage.sync.set({ gameList }); + await chrome.storage.local.set({ gameList }); console.log('Game list saved!'); } @@ -113,7 +113,7 @@ async function processGiveawaysPage(html, gameIds, pointsBudget, page, accumulat if (gameIds.includes(gameId) && !innerWrap.classList.contains('is-faded')) { pointsBudget = Number(pointsBudget) - Number(gameCost) - if (pointsBudget > 0) { + if (pointsBudget >= 0) { accumulatedGiveaways.push({ id: gameId, name: gameNameElement.textContent, link: gameLink, cost: gameCost }); } } diff --git a/manifest.json b/manifest.json index 9f4a0df..09d0d30 100644 --- a/manifest.json +++ b/manifest.json @@ -1,12 +1,13 @@ { "manifest_version": 3, "name": "SteamGifts Automated", - "version": "1.0.1", + "version": "2.0.0", "description": "This Chrome extension enhances the SteamGifts website by allowing you to easily save a list of your preferred game giveaways. With just a single click, it scans open giveaways that match your list and automatically enters you into them. The goal is to streamline your giveaway participation and minimize the number of clicks required each time you visit the SteamGifts website.", "permissions": [ "tabs", "activeTab", - "storage" + "storage", + "unlimitedStorage" ], "host_permissions": [ "http://www.steamgifts.com/*", diff --git a/popup/popup.js b/popup/popup.js index 1c34868..1b1b856 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -2,7 +2,7 @@ let gameIdsToScrape = []; // Function to load game list and populate it in the popup async function loadGameList() { - const result = await chrome.storage.sync.get(['gameList']); + const result = await chrome.storage.local.get(['gameList']); const gameListElement = document.getElementById('gameList'); gameListElement.innerHTML = ''; // Clear existing list @@ -48,9 +48,9 @@ function createRemoveButton(gameId) { // Remove specific game from storage async function removeGameFromList(gameId) { - const result = await chrome.storage.sync.get(['gameList']); + const result = await chrome.storage.local.get(['gameList']); const updatedGameList = result.gameList.filter(game => game.id !== gameId); - await chrome.storage.sync.set({ gameList: updatedGameList }); + await chrome.storage.local.set({ gameList: updatedGameList }); loadGameList(); } @@ -69,6 +69,6 @@ document.addEventListener('DOMContentLoaded', loadGameList); document.getElementById('enterAllBtn').addEventListener('click', triggerGiveawayEntry); document.getElementById('clearListBtn').addEventListener('click', async () => { - await chrome.storage.sync.remove('gameList'); + await chrome.storage.local.remove('gameList'); loadGameList(); }); \ No newline at end of file