akuma06 / Spoiler Tag Webnovel

// ==UserScript==
// @name         Spoiler Tag Webnovel
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Blurs chapter titles!
// @author       akuma06
// @copyright 2018, akuma06 (https://openuserjs.org/users/akuma06)
// @license MIT
// @updateURL https://openuserjs.org/meta/akuma06/Spoiler_Tag_Webnovel.meta.js
// @match        https://www.webnovel.com/book/*
// @grant        none
// @require      http://code.jquery.com/jquery-latest.js
// ==/UserScript==
/* jshint asi:true */

(function () {
  'use strict';
  let $ = window.jQuery
  let blurred = []

  function blur(el) {
    blurred.push($(el).text())
    let showTimeout = null
    $(el).css("filter", "blur(0.5rem)")
    $(el).on("mouseover", function () {
      showTimeout = setTimeout(() => {
        $(this).css({
          filter: "blur(0)"
        })
      }, 3000)
    })
    $(el).on("mouseout", function () {
      clearTimeout(showTimeout)
      $(this).css({
        filter: "blur(0.5rem)"
      })
    })
  }

  function blurEach(elements) {
    elements = elements.filter((v) => blurred.lastIndexOf($(v).text()) == -1)
    elements.forEach((v) => blur(v))
  }
  blur($(".j_chapName"))
  blurEach($(".cha-tit h3").toArray())
  $(document).on("scroll", () => {
    blurEach($(".cha-tit h3").toArray())
  }).on("keydown", (e) => {
    if (e.which == 39 || e.which == 37) {
      blurEach($(".cha-tit h3").toArray())
    }
  })
})();