From 633e1c6424ec5bbbf9569bd88b22603a3b59f8e0 Mon Sep 17 00:00:00 2001 From: Siarhei Siniak Date: Mon, 12 Aug 2024 22:59:56 +0300 Subject: [PATCH] [~] Refactor --- deps/greasyfork/linkedin.user.js | 60 ++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/deps/greasyfork/linkedin.user.js b/deps/greasyfork/linkedin.user.js index c6b6e11..d2d3590 100644 --- a/deps/greasyfork/linkedin.user.js +++ b/deps/greasyfork/linkedin.user.js @@ -364,6 +364,66 @@ const online_fxreader_linkedin = new Linkedin(); entries.empty(); } + let keywords = self.state.search.split(/\s+/).map((o) => { + let action = null; + let word = null; + + if (o.length > 0) + { + if (o[0] == '-') + { + action = 'include'; + word = o.slice(1,); + } + else if (o[0] == '+') + { + action = 'exclude'; + word = o.slice(1,); + } + else + { + action = 'include'; + word = o; + } + } + + return { + action, + word, + }; + }).filter((o) => o.action !== nul); + + let filtered_entries = sorted_entries.filter((o) => { + let match = true; + + let text = JSON.stringify(o); + + for (let k of keywords) + { + if (k.action == 'include') + { + if (text.search(text) == -1) + { + match = false; + } + } + else if (k.action == 'exclude') + { + if (text.search(text) != -1) + { + match = false; + } + } + + if (!match) + { + break; + } + } + + return match; + }) + for (let o of sorted_entries.reverse()) { let raw = JSON.stringify(o[1]);