Created
December 28, 2017 00:07
-
-
Save dob9601/5f16f79825465bf6d8a077700f618626 to your computer and use it in GitHub Desktop.
filter twitter feeds
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
const twitter_filter = (prev_tweet_count = 0) => { | |
const twitter_handles = [] | |
const orgs = document.getElementsByClassName('org-info') | |
for (let i = 0; i < orgs.length; i++) { | |
const org_info = orgs[i].children | |
const children = [].slice.call(org_info) | |
const twitter_url = children.filter( | |
x => x.nodeName === 'A' && x.host === 'twitter.com' | |
) | |
if (twitter_url.length !== 0) { | |
const twitter_account = twitter_url[0].pathname.substr(1) | |
twitter_handles.push(twitter_account) | |
} | |
} | |
const iframe_id = document.getElementById('twitter-widget-0') | |
if (iframe_id !== null) { | |
if (typeof iframe_id.contentWindow !== 'undefined') { | |
const tweet_authors = iframe_id.contentWindow.document.getElementsByClassName( | |
'TweetAuthor-screenName Identity-screenName' | |
) | |
var tweet_count = tweet_authors.length | |
const load_button = iframe_id.contentWindow.document.getElementsByClassName( | |
'timeline-LoadMore-prompt timeline-LoadMore-prompt--edge\ | |
timeline-ShowMoreButton--edge timeline-ShowMoreButton customisable' | |
)[0] | |
console.log(load_button) | |
if (typeof load_button !== 'undefined') { | |
load_button.onclick = function() {twitter_filter(tweet_count)} | |
if (tweet_count > prev_tweet_count) { | |
for (var k = 0; k < tweet_count; k++) { | |
if ( | |
twitter_handles.indexOf(tweet_authors[k].innerHTML.substr(1)) > -1 | |
) { | |
const tweet = getNodesDeep(tweet_authors[k], 5) | |
tweet.style.display = 'none' | |
} | |
} | |
} else { | |
setTimeout(() => twitter_filter(tweet_count), 1000) | |
} | |
} else { | |
setTimeout(() => twitter_filter(), 1000) | |
} | |
} else { | |
setTimeout(() => twitter_filter(), 1000) | |
} | |
} else { | |
setTimeout(() => twitter_filter(), 1000) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment