ChoseRank
by
r_kurain
2011-04-01 [2011/04/01 18:47:42]
copy html from bookmark ranking
@@ -1,7 +1,7 @@
/*
* @title ChoseRank
* @description copy html from bookmark ranking
- * @include http://b.hatena.ne.jp/ranking/*
+ * @include http://b.hatena.ne.jp/ranking*
* @license MIT License
* @require jquery
*/
/*
* @title ChoseRank
* @description copy html from bookmark ranking
* @include http://b.hatena.ne.jp/ranking*
* @license MIT License
* @require jquery
*/
(function(){
var selected = window.getSelection();
if (selected.rangeCount == 0) return;
var range = selected.getRangeAt(0);
var sNode = range.startContainer;
var escapeHTML = function(_strTarget){
var div = document.createElement('div');
var text = document.createTextNode('');
div.appendChild(text);
text.data = _strTarget;
return div.innerHTML;
}
var nodes = document.getElementsByClassName('entry-ranking-info');
for (var i=0;i<nodes.length;i++){
var target = nodes[i].parentNode;
if ( $.contains(target,sNode) ) {
html = escapeHTML(target.innerHTML);
var htmlView = $('<div class=""></div>');
var textArea = $('<textarea>' + html + '</textarea>');
textArea.css({
width: '90%',
height: '90%',
fontSize: 'x-small',
});
textArea.click(function(e){
textArea.select();
e.stopPropagation();
});
htmlView.css({
position: 'absolute',
top: 200,
left: 200,
width: 500,
height: 300,
zIndex: 9999
});
htmlView.append(textArea);
$('body').append(htmlView);
$('body').click(function(){ htmlView.hide() });
return;
}
}
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。