Removes blacklisted articles and news sources from Google News.
当前为
// ==UserScript==
// @name Google News Filter
// @namespace http://www.google-news-filter.com
// @description Removes blacklisted articles and news sources from Google News.
// @include *//news.google.com/*
// @grant none
// @version 1.0.4
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js
// ==/UserScript==
$(function() {
// add new blacklist terms here (case-insensitive);
var $blacklist = [
'kardashian',
'miley cyrus',
];
// end blacklist
// convert blacklist items to lowercase:
$blacklist = $.map( $blacklist, function(n,i) { return n.toLowerCase(); });
// add count div to display statistics:
var $count = 0;
var $matched = '';
var $story = '';
$('#main-wrapper').prepend('<div style="position:fixed;top:0;right:0;padding:2px 6px 0 0;z-index:1000;cursor:pointer;" id="count"></div>');
// search for and remove blacklisted stories:
$('.titletext,.al-attribution-source,.source-pref').each(function() {
var $titletext = $(this).text().toLowerCase();
for (var i=0; i < $blacklist.length; i++) {
if ( $titletext.indexOf( $blacklist[i] ) > -1 ) {
$(this).parents('.blended-wrapper, .small-story').remove();
$count = $count + 1;
$matched += $blacklist[i] +'<br>';
break
}
if ( $count == 1 ) { $story = " story" } else { $story = " stories" } ;
}
// update statistics and add matched terms:
$('#count').text($count + $story +' removed').append('<p id="matched" style="display:none;background:white;margin:0;padding:0.5em;"><b>Matched terms:</b><br>'+$matched+'</p>');
});
// show/hide matched terms by clicking count div:
$('#count').on('click',function() {
$('#matched').toggle(500,function(){
$(this).toggleClass('visible');
});
});
$(document).on('click',function() {
if ( $('#matched').not(':animated').hasClass('visible') ) {
$('#matched').removeClass('visible').hide(500);
};
});
});