Worm comments spoiler protector

Disables tags and comments newer than 2 days. JQuery required.

目前為 2017-08-04 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Worm comments spoiler protector
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Disables tags and comments newer than 2 days. JQuery required.
  6. // @author ShareDVI
  7. // @match https://parahumans.wordpress.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. // How many days ahead are allowed
  14. var DAYS = 2;
  15. // Get chapter release date, thank gods of semantic web
  16. var chapter = Date.parse(jQuery("time.entry-date").attr("datetime"));
  17. // If something went wrong, better kill all comments
  18. if(!chapter) chapter=0;
  19. // Filter all comments newer than days
  20. jQuery("article.comment").filter(function(i,e) {return Date.parse(jQuery(e).find("time").attr("datetime")) >= chapter + 2*86400*1000;}).hide().remove();
  21. // Delete tags
  22. jQuery("a[rel=tag]").hide().remove();
  23. // Add warning so that you know it's enabled
  24. jQuery("#comments-title").append("<b style='color:green; font-size:150%'>Spoiler protection on!</b>");
  25. })();