Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save theletterf/a7cace55c85755dc1497b96cb3c7671e to your computer and use it in GitHub Desktop.
Save theletterf/a7cace55c85755dc1497b96cb3c7671e to your computer and use it in GitHub Desktop.
UserScript for blocking those annoying posts with one sentence per paragraph
// ==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