LoginSignup
4
0

More than 5 years have passed since last update.

読んでる記事を Twitter 共有するブックマークレット#NowBrowsing

Last updated at Posted at 2017-10-05

#NowBrowsing は音楽を共有する なうプレ のブラウジング版です。

実は Chrome Extension も複数作られています。
自分が使っている理由は、シェアボタンがないページの共有や、なうプレと同じ感覚です(自分の行動ログのシェア)。

コード

(function() {
    const url= window.location.href ;
    const encodedUrl = encodeURIComponent(url);
    const text = encodeURIComponent(`見てる - ${document.title}`);
    const twitterShareUrl = `https://twitter.com/intent/tweet?text=${text}&url=${encodedUrl}&hashtags=NowBrowsing`;
    console.log(twitterShareUrl);
    window.open(twitterShareUrl, '', 'width=550, height=420');
})();

↓ブックマークする対象

Bookmarklet
javascript:(function() { const url= window.location.href ; const encodedUrl = encodeURIComponent(url); const text = encodeURIComponent(`見てる - ${document.title}`); const twitterShareUrl = `https://twitter.com/intent/tweet?text=${text}&url=${encodedUrl}&hashtags=NowBrowsing`; console.log(twitterShareUrl); window.open(twitterShareUrl, '', 'width=550, height=420'); })();

なぜブックマークレットなのか

小さな Chrome Extension をいれるとメンテナンスされずに突然使えなくなる経験が多かったことが一つです。
特に今回は"Twitterにテンプレートつきで投稿する"だけの小さな機能です。Chrome Extension はオーバースペックかなという印象です。
最近ちょっとしたことにはブックマークレットをよく作っています。Chrome Extension 作るまでもないときに味がよいです。

※決して Chrome Extension Disではありません。

4
0
3

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
4
0