Last active
March 4, 2021 02:34
-
-
Save theletterf/a7cace55c85755dc1497b96cb3c7671e to your computer and use it in GitHub Desktop.
UserScript for blocking those annoying posts with one sentence per paragraph
This file contains 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 LinkedIn No-Storytelling-Bait-Posts | |
// @version 1.0 | |
// @description Hide those annoying posts with one sentence per paragraph. | |
// @match https://www.linkedin.com/* | |
// @grant none | |
// @inject-into content | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const storySelector = '.feed-shared-update-v2'; | |
function blockAnnoyingPosts() { | |
const stories = document.querySelectorAll(storySelector); | |
for (const story of stories) { | |
if (story.style.display == 'none') { | |
continue; | |
} | |
const content = story.innerText; | |
var count = content.match(/^[a-zA-Z0-9\s*+=',`|{}:;!?\"()\[\]-]*\.{1}\n/gm).length; | |
console.log(count); | |
if (count > 4) { | |
console.debug('Blocked annoying storytelling', story); | |
story.style.display = 'none'; | |
} | |
} | |
} | |
const observer = new MutationObserver(blockAnnoyingPosts); | |
observer.observe(document.body, { | |
'childList': true, | |
'subtree': true | |
}); | |
blockAnnoyingPosts(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment