您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
ユーザ拒否リストに引っかかった動画を非表示にする
当前为
// ==UserScript== // @name Nico Excluder // @namespace https://i544c.github.io // @version 0.1.2 // @description ユーザ拒否リストに引っかかった動画を非表示にする // @author i544c // @match https://www.nicovideo.jp/ranking/* // @grant GM_getValue // @grant GM_xmlhttpRequest // @run-at document-end // @license MIT // ==/UserScript== (() => { 'use strict'; /* * Hi! * You must set `denyUserList` to UserScript Manager. */ const denyUserList = GM_getValue('denyUserList', []); const contentIdQueue = []; window.setInterval(async () => { if (contentIdQueue.length === 0) return; const contentId = contentIdQueue.shift(); const userId = await getVideoMeta(contentId); console.log(contentId, userId); if (denyUserList.includes(userId)) { console.log('Goodbye!', `https://ext.nicovideo.jp/api/getthumbinfo/${contentId}`); document.querySelector(`div.MediaObject[data-video-id=${contentId}`).remove(); } }, 1000); const observer = new MutationObserver(mutations => { mutations.forEach(mutation => { if (mutation.type === 'attributes') { const contentId = mutation.target.parentElement.getAttribute('data-deflist-item-id'); if (!contentId || contentIdQueue.includes(contentId)) return; contentIdQueue.push(contentId); } }); }); const thumbs = document.querySelectorAll('div.Thumbnail-image'); thumbs.forEach(thumb => { observer.observe(thumb, { attributes: true }); }); const getVideoMeta = contentId => new Promise((resolve, _reject) => { const url = encodeURI(`https://ext.nicovideo.jp/api/getthumbinfo/${contentId}`); GM_xmlhttpRequest({ url, onload: meta => { const { responseText } = meta; const domparser = new DOMParser(); const response = domparser.parseFromString(responseText, 'text/xml'); const userId = response.getElementsByTagName('user_id')[0].textContent; resolve(userId); }, }) }); })();