Last active
January 24, 2023 02:17
-
-
Save pacochi/a17600139f65e57cd2b2a65b6502796a to your computer and use it in GitHub Desktop.
トゥートを別タブで開いた時に狭くします。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name [Mastodon] open permalink in a narrow page | |
// @namespace hen.acho.co | |
// @include https://pawoo.net/web/* | |
// @include https://mstdn.maud.io/* | |
// @version 1.230124 | |
// @description view only toot | |
// @downloadURL https://gist.github.com/pacochi/a17600139f65e57cd2b2a65b6502796a/raw/mastodon_open_narrow_page.user.js | |
// @run-at document-idle | |
// @grant none | |
// ==/UserScript== | |
document.querySelector('#mastodon')?.addEventListener('click', e => { | |
if (e.target.nodeName == 'TIME' && e.target.parentNode.className == 'status__relative-time') { | |
e.stopPropagation(); | |
e.preventDefault(); | |
//window.open(e.target.parentNode.href, '_blank', 'width=600'); | |
const url = e.target.parentNode.href; | |
const win = window.open(); | |
const E = (name, attr) => win.document.body.append(Object.assign(win.document.createElement(name), attr)); | |
E('input', { value: url, style: ` | |
width: 600px; | |
display: block; | |
margin: 0px auto; | |
`, onclick: e => { | |
e.target.select(); | |
win.document.execCommand('copy'); | |
e.stopPropagation(); | |
} }); | |
E('iframe', { src: url, style: ` | |
width: 600px; | |
height: 95%; | |
display: block; | |
margin: 0px auto; | |
`}); | |
win.document.title = e.target.closest('[aria-label]').getAttribute('aria-label'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment