Created
December 21, 2022 07:51
-
-
Save hyuki/972cbe696f383cb1051ec47dd8e5f3fd to your computer and use it in GitHub Desktop.
ShareToMastodon.js - ブラウザで見ているWebページをマストドンに投稿するブックマークレット
◆結城浩@social.hyuki.net: "のえるさんのブックマークレットを私がよく使う形式に直しました…" - 結城浩のマストドン
https://social.hyuki.net/@hyuki/109550580576172716
参照時のタイトルを入力できるように修正したものです。
/*
* ShareToMastodon.js
* ブラウザで見ているWebページをマストドンに投稿するブックマークレット
* cf. https://fedibird.com/@noellabo/109549491307414163
*/
function start() {
const server = 'mastodon.example.com';
const visibility = 'public';
const url = document.URL;
let title = prompt("URL投稿タイトル(BSですべて削除すると「参照:」になります)。", '◆' + document.title);
if (title == '') {
title = '参照:';
}
const text = encodeURIComponent(`\r\n${title}\r\n${url}`);
window.open(`https://${server}/share?visibility=${visibility}&text=${text}`);
}
start();
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ブックマークレットに変換するときにはこちらのサイトを使っています。
◆Bookmarklet Creator with Script Includer - Peter Coles
https://mrcoles.com/bookmarklet/