// ==UserScript== // @name 2つのブコメを比較 // @description 比較したいブコメページを入力→コメントがユーザーごとに並ぶ // @include https://b.hatena.ne.jp/entry/* // ==/UserScript== /* * @title 2つのブコメを比較 * @description 比較したいブコメページを入力→コメントがユーザーごとに並ぶ * @include https://b.hatena.ne.jp/entry/* * @license CC0 * @javascript_url */ (async () => { document.documentElement.scrollTop = document.documentElement.scrollHeight const regexpEscape = s => s.replace(/[\\^$.*+?()[\]{}|]/g, '\\$&'); const regexp = new RegExp(regexpEscape("https://b.hatena.ne.jp/entry/") + "(s/)*(.+)"); const BtoURL = s => s.replace(regexp, (_, p1, p2) => (p1 ? "https://" : "http://") + p2); const bookmarks = (await (await fetch('https://b.hatena.ne.jp/entry/jsonlite/?url=' + encodeURIComponent(BtoURL(prompt('比較ブクマURL', ''))))).json()).bookmarks; bookmarks.forEach(bookmark => { const targetElement = document.querySelector(`.is-active.bookmarks-sort-panel [data-user-name="${bookmark.user}"] .entry-comment-text`); targetElement ? (targetElement.style.display = "flex", targetElement.style.grid = "auto-flow / 50% 50%", targetElement.style.gap = "5px") : null; targetElement?.insertAdjacentHTML?.('beforeend', `