Chromeでつぶやくだけのユーザスクリプトを少しいじってみた
Chromeでつぶやくだけのユーザスクリプト - あたご型護衛艦日記でGoogle Chromeで見ているページをつぶやくユーザスクリプトなるものが公開されていたので、本当にちょっとだけいじってみました。グリモンでも動きます。
以下のコードをテキストエディタなどに貼りつけて、「任意の名前.user.js」という形式のファイル名で保存して、ブラウザにドラッグアンドドロップしてください。スタイルなどは適当に弄って見た目よくして使うこと推薦です。
こんな感じに右はじに何か飛び出ているので
マウスを乗っけると飛び出てきて、Tweetのリンクを押せばポストできます。
Chrome extensionで同様のものを作ろうかな。
// ==UserScript== // @name Watch Now! on Chrome KAI // @include http://* // @include https://* // ==/UserScript== (function(){ var title = document.title; var url = location.href; var val = 'Watch Now! ' + title + ' ' + url; var tweet = 'http://twitter.com/home/?status=' + encodeURIComponent(val); var showTweetbox = function(){ tweetBox.style.right = "0px"; } var hideTweetbox = function(e){ tweetBox.style.right = "-63px"; } var isResize = false; var tweetBox = document.getElementById("watch_now"); if (!tweetBox) { tweetBox = document.createElement("div"); tweetBox.id = "watch_now"; tweetBox.style.position = "fixed"; tweetBox.style.width = "80px"; tweetBox.style.height = "20px"; tweetBox.style.right = "-63px"; tweetBox.style.top = "30px"; tweetBox.style.border = "1px solid #CCC"; tweetBox.style.backgroundColor = "rgba(221, 238, 246, 0.8)"; tweetBox.style.overflow = "auto"; tweetBox.addEventListener("mouseover", showTweetbox, false); tweetBox.addEventListener("mouseout", hideTweetbox , false); window.addEventListener("resize", hideTweetbox, false); document.body.appendChild(tweetBox); } tweetBox.innerHTML = '<span style="margin-left:0px;font-weight:bold;"><img src="http://nicotag.sakura.ne.jp/twiticon.png"><a href="' + tweet + '" target="_blank" style="text-decoration:none;">Tweet</a></span>'; document.body.insertBefore(tweetBox, document.body.firstChild); })();