// ==UserScript== // @name はてなブックマークメタブ展開 // @description コメントメタブと2階ブクマを展開します。説明→https://realtor-readyabooks.hatenablog.com/entry/2022/12/28/153626 // ==/UserScript== // ==UserScript== // @name はてなブックマークメタブ展開 // @title はてなブックマークメタブ展開 // @namespace https://let.hatelabo.jp/Lhankor_Mhy/let/jtaB0fa4gYAA // @version 0.13.2 // @description コメントメタブと2階ブクマを展開します。説明→https://realtor-readyabooks.hatenablog.com/entry/2022/12/28/153626 // @author Lhankor_Mhy // @match https://b.hatena.ne.jp/entry/* // @icon https://b.hatena.ne.jp/favicon.ico // @license CC0 // @noframes // @grant none // @javascript_url // ==/UserScript== (async () => { const APIURL = 'https://b.hatena.ne.jp/entry/jsonlite/?url=' document.body.insertAdjacentHTML('beforeend', ` `) document.querySelector('.entry-comments').insertAdjacentHTML('beforeend', `
`) // メタブありますポップオーバーのイベント設定 const metahatebuPopover = document.getElementById('metahatebu-popover'); metahatebuPopover.addEventListener('click', ((i = -1) => event => { const metabues = document.querySelectorAll('[data-metabu]'); if (event.target.matches('[data-metabuprev]')) i--; if (event.target.matches('[data-metabunext]')) i++; i = metabues.length ? (i + metabues.length) % metabues.length : 0; metabues[i].scrollIntoView({ behavior: "smooth", block: "end", inline: "nearest" }); metabues.forEach((metabu, j) => metabu.classList.toggle('focus', i == j)); })()) // ポップオーバーフォールバック const metahatebuPopoverOpen = () => { if (HTMLElement.showPopover) { metahatebuPopover.showPopover() } else { metahatebuPopover.show() } } // ブクマ展開(x-template再利用) const addBookmark = function (targetElement, bookmark, eid) { document.querySelector(`[href="/entry/${eid}/comment/${bookmark.user}"]`)?.closest('.entry-comment-contents > .entry-comment-contents').remove(); targetElement.insertAdjacentHTML( 'beforeend', document.getElementById('autoloader-bookmark-item').textContent .replaceAll('