Last active
December 19, 2017 10:06
-
-
Save androidfanatic/f150dac1fa963170267f623d4492618a 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 Remove Famous LinkedIn Posts | |
// @namespace RemoveFamousLinkedInPosts | |
// @description Remove Famous LinkedIn Posts | |
// @include https://www.linkedin.com/* | |
// ==/UserScript== | |
var MAX_NUM_LIKES = 150; | |
var DEBUG = false; | |
var INTERVAL = 500; | |
function removeFamousLinkedInPosts() { | |
if ( DEBUG ) console.log('removeFamousLinkedInPosts'); | |
var articles = document.getElementsByTagName('article'); | |
if ( DEBUG ) console.log('Found ' + articles.length + ' articles'); | |
for (var i = 0; i < articles.length; i++) { | |
var article = articles[i]; | |
var likeButton = article.querySelector('.feed-base-social-counts__num-likes'); | |
if (likeButton) { | |
var likeText = likeButton.innerText; | |
if (likeText && likeText.length > 0 && likeText.match(/[0-9]+ Likes/)) { | |
if ( DEBUG ) console.log('Found like text: ' + likeText); | |
var numLikes = 0; | |
try { | |
numLikes = parseInt(likeText.split(' ')[0].replace(',', '')); | |
} catch (e) { | |
if (DEBUG) console.log(e); | |
} | |
if (numLikes > MAX_NUM_LIKES) { | |
console.log('Hidden: ' + likeText); | |
article.remove(); | |
} | |
} | |
} | |
} | |
} | |
window.addEventListener('load', function() { | |
removeFamousLinkedInPosts(); | |
setInterval(removeFamousLinkedInPosts, INTERVAL); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment