ニコニコ動画のニコレポにAutoPager機能を追加する
当前为
// ==UserScript==
// @name Nicorepo AutoPagerize
// @namespace https://foooomio.net/
// @description ニコニコ動画のニコレポにAutoPager機能を追加する
// @version 0.6
// @author foooomio
// @license MIT License
// @match https://www.nicovideo.jp/my*
// @match https://www.nicovideo.jp/user/*
// @run-at document-idle
// @grant none
// ==/UserScript==
(() => {
'use strict';
const $ = document.querySelector.bind(document);
const isNewMyPage = !!$('.UserPage-main');
const mutationSelector = isNewMyPage ? '.UserPage-main' : '.nicorepo-page';
const intersectionSelector = isNewMyPage ? '.NicorepoTimeline-more' : '.NicorepoPastFetcher .next-page-link';
if (!$(mutationSelector)) {
return;
}
const autopager = new IntersectionObserver(([entry]) => {
if (entry.isIntersecting && !entry.target.parentElement.classList.contains('loading')) {
entry.target.click();
}
});
new MutationObserver(() => {
const target = $(intersectionSelector);
if (target) {
autopager.disconnect();
autopager.observe(target, { childList: true });
}
}).observe($(mutationSelector), { childList: true, subtree: true });
})();