Skip to content

Commit

Permalink
switch storage.local instead of storage.sync to avoid storage limits …
Browse files Browse the repository at this point in the history
…and allow for larger game list libraries
  • Loading branch information
marinoffDev committed Nov 14, 2024
1 parent dc45a35 commit 7a041a4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions content/contentScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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!');
}

Expand Down Expand Up @@ -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 });
}
}
Expand Down
5 changes: 3 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -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/*",
Expand Down
8 changes: 4 additions & 4 deletions popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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();
}

Expand All @@ -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();
});

0 comments on commit 7a041a4

Please sign in to comment.