Created
October 12, 2014 18:44
-
-
Save kamikat/949e6dee8259fa2b652a to your computer and use it in GitHub Desktop.
Zerochan Blacklisted Feed Killer - Auto-hide feeds from feedly blacklisted by zerochan.net
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 Zerochan Blacklisted Feed Killer | |
// @version 0.0.1 | |
// @description Auto-hide feeds from feedly blacklisted by zerochan.net | |
// @include https://feedly.com/* | |
// @include http://feedly.com/* | |
// @run-at document-end | |
// @namespace https://github.com/kirisetsz | |
// ==/UserScript== | |
var shouldFilter = function (node, feed) { | |
return (function () { | |
return feed.feed_source.match(/.*zerochan\.net.*/) && (function (hot) { | |
return hot && hot.innerText.trim() == '500+'; | |
})(node.querySelector('span.hot, .nbrrecommendations')); | |
})() && true; | |
}; | |
var obtainFeedData = function (node, t) { | |
var el_feed_title, el_item_title, el_item_description; | |
el_feed_title = (node.querySelector('span.sourcetitle>a, a.sourcetitle') || document.querySelector('a.feedtitle')); | |
el_item_title = node.querySelector('a.title'); | |
el_item_summary = node.querySelector('span.u' + t + 'Summary, .summary, .bodyEntry'); | |
var feed_title, feed_source, item_title, item_source, item_description; | |
feed_title = el_feed_title.innerText; | |
feed_source = (el_feed_title.getAttribute('data-uri') || | |
el_feed_title.getAttribute('data-feedid')).match(/^(?:.*\/)*feed\/(.*)$/)[1]; | |
item_title = el_item_title.innerText; | |
item_link = el_item_title.href; | |
item_summary = el_item_summary && el_item_summary.innerHtml || ''; | |
return { | |
feed_title: feed_title, | |
feed_source: feed_source, | |
item_title: item_title, | |
item_link: item_link, | |
item_summary: item_summary, | |
}; | |
}; | |
var mo = new MutationObserver(function (mutations) { | |
mutations.forEach(function (mutation) { | |
Array.prototype.slice.call(mutation.addedNodes).forEach(function (node) { | |
var match = node.className && node.className.match(/u[0-9]Entry /); | |
if (match) { | |
var t = match[1]; | |
if (shouldFilter(node, obtainFeedData(node, t))) { | |
node.style.display = 'none'; | |
node.querySelector('[data-buryentryid]').click(); | |
console.debug('removed', node); | |
} | |
} | |
}); | |
}); | |
}); | |
mo.observe(document.body, { childList: true, subtree: true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment