@peccul is peccu

(love peccu '(emacs lisp cat outdoor bicycle mac linux coffee))

見ているページをTwitterにつぶやくブックマークレット

macSafariのバージョンが12?になってShareメニューから呟けなくなったのが不便。 ブックマークレットにした。

↓これをブックバークバーにドラッグしていただければ。

Tweet

コードはこんな感じ

(function(){
  let title = document.title;
  let url = document.location.href;
  let comment = prompt('Tweet Comment', '');
  if(comment === null){
    return;
  }

  let text = encodeURIComponent(`${comment} / ${title}`);
  let intent = `https://twitter.com/intent/tweet?text=${text}&url=${encodeURIComponent(url)}`;
  return window.open(intent, '_blank');
})()

参考

Guides — Twitter Developers