Forked from miglen/news-feeds-eradicator-linkedin.user.js
Last active
August 27, 2024 14:13
-
-
Save JesperDramsch/839365c85133927f694bf5113c77a2f1 to your computer and use it in GitHub Desktop.
News Feed Eradicator for LinkedIn
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 News Feed Eradicator for LinkedIn | |
// @namespace http://miglen.com/ | |
// @version 0.5 | |
// @description News Feed Eradicator for LinkedIn | |
// @author Miglen Evlogiev ([email protected]) | |
// @match https://www.linkedin.com/feed/ | |
// @grant none | |
// @downloadURL https://gist.github.com/JesperDramsch/839365c85133927f694bf5113c77a2f1/raw/news-feeds-eradicator-linkedin.user.js | |
// @updateURL https://gist.github.com/JesperDramsch/839365c85133927f694bf5113c77a2f1/raw/news-feeds-eradicator-linkedin.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('scaffold-layout__main')[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 | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've modified this to add
Since
/
will redirect you to/feed
(but Tampermonkey doesn't seem to pick up on the redirect and activate)