Skip to content

Instantly share code, notes, and snippets.

@tarchan
Last active December 19, 2015 08:19
Show Gist options
  • Save tarchan/5924435 to your computer and use it in GitHub Desktop.
Save tarchan/5924435 to your computer and use it in GitHub Desktop.
コメント付きでURLを投稿します。
(function(){
var link = location.href;
var title = window.getSelection() + '' || document.title;
//var text = window.getSelection();
var quote = title + ' ' + link + ' ';
//var total = {};
//var year = '2012';
//var all = false;
var nick = 'たーちゃん';
function init() {
$('<div/>').css({
position: 'fixed',
left: 0,
top: 0,
width: '100%',
height: '100%',
zIndex: 1000,
backgroundColor: 'rgba(0,0,0,.7)',
color: '#fff',
fontSize: 30,
textAlign: 'center',
paddingTop: '15em'
}).attr('id', '___overlay').text('cafebot> ' + quote).appendTo('body');
var text = window.prompt('投稿:', quote);
//text && alert(text);
/*
$.post(
'/lchat7/talk',
{
'ch':'javabreak',
'text':quote
},
function(data){
alert("success");
}
)
.fail(function(){alert("error");});
*/
var data = {
'ch':'javabreak',
'nick':nick,
'text':quote
};
var form = $('<form method="POST" />').attr('id', '___form').attr('acceptCharset', 'utf-8').attr('action', 'http://cafebabe.ddo.jp/lchat7/talk').hide().appendTo('body');
for(key in data){
var input = document.createElement('input');
input.setAttribute('type', 'hidden');
input.setAttribute('name', key);
input.setAttribute('value', data[key]);
form.append(input);
}
form.submit();
$('#___overlay').remove();
$('#___form').remove();
return false;
}
if(typeof $ !== 'function') {
var d=document;
var s=d.createElement('script');
s.src='//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js';
s.onload=init;
d.body.appendChild(s);
} else {
init();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment