Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
News Feed Eradicator for LinkedIn
// ==UserScript==
// @name News Feed Eradicator for LinkedIn
// @namespace http://miglen.com/
// @version 0.4
// @description News Feed Eradicator for LinkedIn
// @author Miglen Evlogiev (hi@miglen.com)
// @match https://www.linkedin.com/*
// @grant none
// @downloadURL https://gist.github.com/miglen/4f1bccf15b63944675d34149dff0bc3d/raw/news-feeds-eradicator-linkedin.user.js#.user.js
// @updateURL https://gist.github.com/miglen/4f1bccf15b63944675d34149dff0bc3d/raw/news-feeds-eradicator-linkedin.user.js#.user.js
// ==/UserScript==
/**
Similiar to the News Feed Eradicator for LinkedIn it's just not
a separate extention but a Grease Monkey Script.
Installation instructions:
1. Install the latest version of Tamper Monkey: https://tampermonkey.net
2. Click on Raw on the current file, your browser should
detect the script and allow you to install it,
otherwise copy the download url above and paste in your browser.
*/
(function() {
'use strict';
// Set the main div containing the news feeds
var core_rail = document.getElementsByClassName('core-rail')[0];
function addCss(css) {
var head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet) {
// This is required for IE8 and below.
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
head.appendChild(style);
}
// Hide a css selector element
function hideElement(css_selector) {
addCss(`${css_selector} {display:none;visibility:hidden;}`);
}
function applicationContentMutation(mutation) {
if (!window.location.pathname.startsWith("/feed")) {
return true;
}
// Placeholder text, change it to whatever you want
var div = `
<div style="padding:30px;">
<h3>Don't "work harder." Instead:</h3>
<br>
<ul>
<li>Cut away distractions. Use social media intentionally.</li>
<li>Stop doing fake work and being busy, focus on the results.</li>
<li>Ask for help & engage your mentors.</li>
<li>Solicit criticism.</li>
<li>Automate what can be automated in tools and processes.</li>
<li>Exercise & Get more sleep. Take care of your self!</li>
</ul>
<br>
<h4>Whatever you do, don't "work harder." It's pretty much never the answer. Work smarter!<h4>
</div>`;
// Replace the news feeds with the placeholder text
core_rail.lastElementChild.innerHTML = div;
}
// Various css selectors of elements to be hidden
var css_selectors = [
'div[data-id^="urn:li:activity:"]', // feed activity
'#feed-nav-item .nav-item__badge--doughnut', // feed notifications
'div.feed-shared-update-v2', // Ads in the feed
'.ad-banner-container', // Ads container
'.feed-shared-navigation-module', // Discover More container
'.feed-shared-navigation-module--v2', // Discover More container
'.feed-follows-module', // Add to your feed container
'.sort-dropdown__dropdown-trigger', // Sort dropdown trigger
'.feed-shared-news-module' //Shared news module
]
// Hide all elements
hideElement(css_selectors.join(', '))
// Set the placeholder text initially
applicationContentMutation();
// Hook into the news feed mutations
const applicationContentObserver = new MutationObserver(function(mutations) {
mutations.forEach(applicationContentMutation);
});
applicationContentObserver.observe(core_rail, {
childList: true
});
})();
@JawadS

This comment has been minimized.

Copy link

JawadS commented Dec 8, 2018

Awesome stuff! really good work. thanks dude!

@miglen

This comment has been minimized.

Copy link
Owner Author

miglen commented Dec 13, 2018

Glad that you like it @JawadS 👍

@garydonovan

This comment has been minimized.

Copy link

garydonovan commented Jan 7, 2019

Thank you so much!

@moebg

This comment has been minimized.

Copy link

moebg commented Jan 13, 2019

This is great! Thank You so much! If you can get the time, would you be able to update the script to get rid of these elements as well? https://prnt.sc/m6odi4. At least the hashtags, and some stuff that's irrelevant. Thanks! :)

@miglen

This comment has been minimized.

Copy link
Owner Author

miglen commented Jan 17, 2019

Thanks for your suggestions @moebg I have updated it with them. Also, I was using it on top of uBlock Origin, which was hiding most of the ads, so I've added that as well. Let me know if you see any bugs so I can fix them accordingly.

@miglen

This comment has been minimized.

Copy link
Owner Author

miglen commented Jan 28, 2019

Revision 0.4 - Updated sort dropdown trigger and added & added Matt T. suggestion for Suggested news stories

@alexetcetc

This comment has been minimized.

Copy link

alexetcetc commented Apr 18, 2019

Thank you - this works great!
I am free of Linkedin spam.

@mthurmond

This comment has been minimized.

Copy link

mthurmond commented Oct 28, 2019

Thanks again for this excellent script!

@miglen

This comment has been minimized.

Copy link
Owner Author

miglen commented Oct 28, 2019

Thanks again for this excellent script!

Glad it makes people happy and hopefully productive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.