引用なう
by
namusyaka
2012-04-11 [2012/04/11 14:42:11]
ページ内容を選択(しなくても可)してTwitterにつぶやくスクリプト。
/*
* @title 引用なう
* @description ページ内容を選択(しなくても可)してTwitterにつぶやくスクリプト。
* @include http://*
* @license MIT License
* @require
*/
(function () {
function getSelectedText () {
if('\v' === 'v')
return document.selection.createRange().text;
else
return ('getSelection' in window ? window : document).getSelection().toString();
};
var title = document.getElementsByTagName('title')[0].innerHTML
, selectedText = getSelectedText()
, uri = location.href
, result = '';
if(selectedText)
result += '「' + selectedText + '」';
if(title)
result += title + ' | ';
if(uri)
result += uri;
window.open('http://twitter.com/home?status=' + encodeURIComponent(result));
return;
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。