diff --git a/background.js b/background.js index 01e53febd0ccf40079b9f512bad79aa180587f32..b10c2cdaebc9e98fad0668d1294993a4fe4fc5e6 100644 --- a/background.js +++ b/background.js @@ -149,10 +149,11 @@ function getTargetStashSize() { } /** - * Checks token stash and refills if possible + * Checks token stash and tries to refill if refill is set to true + * @param {boolean} refill * @returns {boolean} True if stash now holds at least as many tokens as the current tokensPerSearch value. */ -async function checkTokenStash() { +async function checkTokenStash(refill) { console.log("checking token stash"); let { tokenStash: currentStash, @@ -169,7 +170,7 @@ async function checkTokenStash() { let targetStashSize = getTargetStashSize(); if (currentStash > refillThresholdSize) { return true; - } else if (activeKey) { + } else if (refill && activeKey) { return await refillTokenStash(targetStashSize - currentStash.length); } else { return false; @@ -177,10 +178,6 @@ async function checkTokenStash() { } setTimeout(checkTokenStash,10000); -function tokensAvailable() { - return storageGlobal.tokenStash && storageGlobal.tokenStash.length>=tokensPerSearch; -} - function popTokens(count) { let tokens = [];