Last active
August 9, 2019 18:53
-
-
Save androidfanatic/bacbd4d4c2566f12fafba43fa2fd4c8e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name LinkedinIsFacebookNow | |
| // @version 1 | |
| // @grant none | |
| // @include https://www.linkedin.com/* | |
| // @run-at document-end | |
| // ==/UserScript== | |
| // Idea: | |
| // This script hides all the popular posts. I figured that most of the popular stuff | |
| // that I must know about are already on the news like HN or WSJ or TV etc. | |
| // maximum number of reactions that a post can have and not get flagged as a viral jargon | |
| const MAX_REACTIONS_THRESHOLD = 150; // arbitary number that works for me | |
| // mode = 0 => remove posts | |
| // mode = 1 => just make the background red for flagged posts | |
| // It is advised to run this script with mode = 1 for a week or so, | |
| // to observe the number and type of posts getting flagged | |
| const mode = 0; | |
| const redColor = 'rgba(255, 0, 0, 0.75)'; | |
| const removePopularPosts = () => { | |
| document.querySelectorAll('.relative.ember-view').forEach(feedElem => { | |
| const reactionsElem = feedElem.querySelector('[class*=reactions-count]'); | |
| if (reactionsElem && reactionsElem.textContent) { | |
| try { | |
| const count = parseInt(reactionsElem.textContent.replace(/,/g, ''), 10); | |
| if (count > MAX_REACTIONS_THRESHOLD) { | |
| if (mode === 0) { | |
| feedElem.style.backgroundColor = redColor; | |
| feedElem.style.display = 'none'; | |
| } else { | |
| feedElem.style.backgroundColor = redColor; | |
| } | |
| } | |
| } catch(e) { | |
| console.error(e); | |
| } | |
| } | |
| }); | |
| } | |
| // Run once | |
| removePopularPosts(); | |
| // Run every 5 seconds - because CPU is cheap now and async network requests within a SPA are difficult to intercept | |
| setInterval(function() { | |
| removePopularPosts(); | |
| }, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment