diff --git a/content.js b/content.js index 245f473..08b54ca 100644 --- a/content.js +++ b/content.js @@ -1,6 +1,7 @@ const state = { postsLength: 0, wordsLength: 0, + lastPostIndex: 0, }; const methodsCases = { @@ -11,13 +12,15 @@ const methodsCases = { if (allPosts.length === state.postsLength && currentWords.length === state.wordsLength) return; state.postsLength = allPosts.length; state.wordsLength = currentWords.length; - allPosts.forEach((post) => { - currentWords.forEach((word) => { - if (post.style.display === 'none') return; + allPosts.slice(state.lastPostIndex).forEach((post, i) => { + currentWords.find((word) => { + if (post.style.display === 'none') return true; if (post.textContent.toLowerCase().includes(word.toLowerCase())) { post.style.display = 'none'; - return undefined; // critical return + state.lastPostIndex = i; + return true; } + return false; }); }); }); diff --git a/popup.js b/popup.js index 36a8c1a..b888a28 100644 --- a/popup.js +++ b/popup.js @@ -1,7 +1,7 @@ function listWords() { window.chrome.storage.sync.get(['words'], (res) => { const { words = '[]' } = res; - const listItems = JSON.parse(words).reduce((agg, itm) => agg.concat(`