0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ブックマークレット×GoogleChat - Webhook

Last updated at Posted at 2023-12-22

記事概要

ブックマークレットを使い、表示ページのURLと選択している文字列をGoogleChatのスペース宛に送信する。

方法

下記JSをブックマークレットに登録する。

javascript: (() => {
	const text = window.getSelection().toString();
	const url = location.href;
	if (window.confirm(text + '\n\n↑メッセージを投げますか?')) {
		const webhook = 'https://chat.googleapis.com/v1/spaces/XXXXX';
		fetch(webhook, {
			method: 'POST',
			headers: {
				'Content-Type': 'application/json; charset=UTF-8'
			},
			body: JSON.stringify({
				text: text + '\n' + url
			})
		});
	}
})();

使い方

文字列を選択した状態で、登録したブックマークレットを利用する。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?