您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
2024/6/21 13:43:27
// ==UserScript== // @name ニコニコ動画(Re:仮)説明文linkify // @namespace net.ghippos.nicovideo.rekari.linkify // @match https://www.nicovideo.jp/watch_tmp/* // @grant none // @version 1.1 // @author mohemohe // @description 2024/6/21 13:43:27 // @license WTFPL // ==/UserScript== const linkify = async (description) => { for (const node of description.childNodes) { const content = node.textContent; if (!content) { continue; } const links = content.match(/([ns]m\d+)/g); if (links) { let replacedContent = content; const replaces = {}; for (const link of links) { const exists = await fetch(`https://www.nicovideo.jp/api/watch/tmp/${link}?_frontendId=6&_frontendVersion=0.0.0`); replacedContent = replacedContent.replace(link, `<a href="https://www.nicovideo.jp/watch_tmp/${link}" style="color: #0969da; text-decoration: underline">${link}${exists.status == 200 ? "[公開中]" : "[非公開]"}</a>`); } const span = document.createElement("span"); span.innerHTML = replacedContent; node.parentNode.replaceChild(span, node); } } }; // NOTE: document.bodyでMutationObserverを試したけど他のサイトと違ってなんか動かなかった const awaiter = setInterval(async () => { const description = document.querySelector("main p"); if (description) { clearInterval(awaiter); await linkify(description); } }, 100);