Greasy Fork is available in English.

ニコニコ動画の検索フィルタの投稿日時の期間の選択肢を増やす

ニコニコ動画の検索フィルタの投稿日時の期間に3ヶ月と1年の選択肢を追加します。

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
// ==UserScript==
// @name        ニコニコ動画の検索フィルタの投稿日時の期間の選択肢を増やす
// @namespace   rinsuki.net
// @match       https://www.nicovideo.jp/search/*
// @match       https://www.nicovideo.jp/tag/*
// @grant       none
// @version     1.1
// @author      -
// @description ニコニコ動画の検索フィルタの投稿日時の期間に3ヶ月と1年の選択肢を追加します。
// ==/UserScript==

(() => {
    const choices = document.querySelector(".searchOption .filterOptionContainer .postTime ul")
    const customChoice = choices.children[choices.children.length-1]
    function dateToNicoString(date) {
        return `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, "0")}-${date.getDate().toString().padStart("0", 2)}`
    }
    const hr = document.createElement("li")
    hr.style = "border-top: 1px solid #999";
    choices.insertBefore(hr, customChoice)
    function add(name, days) {
        const date = new Date(Date.now() - (days * 24 * 60 * 60 * 1000))
        const li = choices.querySelector("li:not(.active)").cloneNode(true)
        li.classList.remove("active")
        const link = li.children[0]
        link.innerText = name
        link.href = link.href.replace(/f_range=\d/, "")
        link.href += `&start=${dateToNicoString(date)}`
        link.href += `&end=${dateToNicoString(new Date())}`
        choices.insertBefore(li, customChoice)
    }
    add("3ヶ月以内", 90)
    add("1年以内", 365)
})()