// ==UserScript== // @name TOKIMEKI View on Bluesky // @namespace https://tokimeki.blue/ // @version 0.1.0 // @description 個別postのメニューにBlueskyで開く項目を追加する // @author mudo34 // @match https://tokimeki.blue/* // @icon https://www.google.com/s2/favicons?domain=tokimeki.blue // @grant none // @noframes // ==/UserScript== (function() { 'use strict'; function onContent(el, e) { const copy = el.parentElement.querySelector('.timeline-menu-list__item--copy-url'); if (!copy) { return; } const jump = copy.cloneNode(true); jump.addEventListener('click', openBluesky); jump.firstChild.innerHTML = ` Open Bluesky `; copy.parentElement.insertBefore(jump, copy.nextSibling); } function openBluesky(e){ const item = e.target.closest('.timeline__item'); const content = item?.querySelector('.timeline__content'); const aturi = content?.getAttribute('data-aturi'); if (!aturi) { return; } const url = aturi.replace( /.+(did:plc:.+)\/app\.bsky\.feed\.post\/(.+)$/, 'https://bsky.app/profile/$1/post/$2' ); console.log(url); const a = document.createElement('a'); a.href = url; a.target = '_blank'; a.style.display = 'none'; document.body.appendChild(a); a.click(); a.remove(); e.target.closest('.timeline__item').querySelector('.timeline-menu-toggle').click(); } function attachEvent(root, type, selector, handler) { root.addEventListener(type, e => { const el = e.target.closest(selector); if (el && root.contains(el)) { handler(el, e); } }); } attachEvent(document, 'click', '.timeline-menu-toggle', onContent); })();