Bangumi Anti-Netabare

屏蔽未看过话播出时间以前的讨论

当前为 2015-07-22 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Bangumi Anti-Netabare
// @namespace   BAN
// @include     /https?:\/\/(bgm|bangumi|chii)\.(tv|in)\/ep\/.+/
// @version     0.3
// @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(typeof match == "undefined") 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 $ep = page.match(/load-epinfo (epBtnAir|epBtnNA)" title=".*?" rel="#prginfo_(\d+)/).slice(2)[0];
  //496541" class="ep_status">抛弃</a></div><span class="tip">中文标题:你多么耀眼<br />首播:2015-04-19
  var $date = page.match((new RegExp($ep + '" 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);
      $('.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);
      })
  });
});