屏蔽未看过话播出时间以前的讨论
当前为
// ==UserScript==
// @name Bangumi Anti-Netabare
// @namespace BAN
// @include /https?:\/\/(bgm|bangumi|chii)\.(tv|in)\/ep\/.+/
// @version 0.4
// @grant none
// @description 屏蔽未看过话播出时间以前的讨论
// ==/UserScript==
//---- Actions on ep. page --------------------------------
//Get the first on air date.
getOnAirDate = function() {
return (new Date($('.epDesc .tip').html().match(/首播:(\d{4}\-\d{1,2}\-\d{1,2})/).slice(1)[0])).valueOf() / 1000;
}
getFloorDate = function($el) {
var match = $el.html().match(/(\d{4})\-(\d{1,2})\-(\d{1,2}) (\d{1,2}):(\d{1,2})/);
if(match === null) return new Date(0);
match = match.slice(1);
//The month start from 0
return (new Date(match[0], match[1] - 1, match[2], match[3], match[4])).valueOf() / 1000;
}
//Check whether the date in .re_info is out of the date first on air.
checkDate = function(floorDate, filterDate) {
return (floorDate > filterDate);
}
getSubjectUrl = function() {
return $('#subject_inner_info a').attr('href');
}
//---- Actions on subject page ----------------------------
getFirstUnwachedEpDate = function(page) {
var match = page.match(/load-epinfo (epBtnAir|epBtnNA)" title=".*?" rel="#prginfo_(\d+)/);
if(match === null) return false;
match = match.slice(2)[0];
//496541" class="ep_status">抛弃</a></div><span class="tip">中文标题:你多么耀眼<br />首播:2015-04-19
var $date = page.match((new RegExp(match + '" class="ep_status.+?首播:(\\d{4}\\-\\d{1,2}\\-\\d{1,2})'))).slice(1)[0];
return (new Date($date)).valueOf() / 1000;
}
//---- Here we go~ ----------------------------------------
$(function() {
//var epOnAirDate = getOnAirDate();
var subjectPage = getSubjectUrl();
$.get(subjectPage, function(subjectPageContent) {
var filterDate = getFirstUnwachedEpDate(subjectPageContent);
if(filterDate) {
$('.re_info').each(function() {
if(checkDate(getFloorDate($(this)), filterDate)) {
//Hide this floor
$(this).parent().children('.inner').children('.reply_content').css({opacity: 0});
$(this).parent().css({background: "#DDDFFF"});
$(this).parent().addClass('banFloor');
}
});
$('.banFloor').click(function() {
$(this).children('.inner').children('.reply_content').animate({
opacity: 1
}, 500);
});
}
});
});