Skip to content

Instantly share code, notes, and snippets.

@lagash
Created July 17, 2009 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lagash/148885 to your computer and use it in GitHub Desktop.
Save lagash/148885 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name 4da4 for twitter
// @namespace http://d.hatena.ne.jp/dalmacija/
// @include *
// ==/UserScript==
var yonda4 = document.createElement('div')
yonda4.setAttribute('style',
'padding:5px;' +
'position:fixed;' +
'top:3px;' +
'left:3px;' +
'font-size:10px;' +
'background:#fff;' +
'color:#000;' +
'border:1px solid #ccc;' +
'z-index:256;' +
'text-align:left;' +
'font-weight:normal;' +
'line-height:120%;' +
'cursor: pointer;');
yonda4.setAttribute('onclick',"javascript:(function(s){s.src='http://amachang.sakura.ne.jp/misc/amazon/search.js';document.body.appendChild(s)})(document.createElement('script'));");
yonda4.innerHTML="読んだ4";
document.body.appendChild(yonda4);
//ポスト用フォームを作る
if(document.location.href=="http://twitter.com/")return false;
var fakeTW = document.createElement('div');
fakeTW.setAttribute('style',
'padding:0px;' +
'position:fixed;' +
'top:25px;' +
'left:3px;' +
'font-size:10px;' +
'background:#fff;' +
'border:1px solid #ccc;' +
'z-index:257;' +
'text-align:left;' +
'font-weight:normal;' +
'line-height:120%;' +
'cursor: pointer;' +
'visibility:hidden');
fakeTW.setAttribute('class','info');
document.body.appendChild(fakeTW);
var txtBX = document.createElement('textarea');
txtBX.setAttribute('tabindex','1');
txtBX.setAttribute('autocomplete','off');
txtBX.setAttribute('accesskey','u');
txtBX.setAttribute('name','status');
txtBX.setAttribute('id','status');
txtBX.setAttribute('rows','2');
txtBX.setAttribute('cols','20');
window.addEventListener('click',function(){
if(txtBX.value!=""){
fakeTW.style.visibility='visible';
sbmt.style.visibility='visible';
}
},false);
fakeTW.appendChild(txtBX);
var sbmt = document.createElement('div');
sbmt.setAttribute('style',
'padding:5px;' +
'position:fixed;' +
'top:100px;' +
'left:3px;' +
'font-size:10px;' +
'background:#fff;' +
'color:#000;' +
'border:1px solid #ccc;' +
'z-index:258;' +
'text-align:left;' +
'font-weight:normal;' +
'line-height:120%;' +
'cursor: pointer;' +
'visibility:hidden;');
sbmt.innerHTML="登録";
sbmt.addEventListener("click", function(){
//-----------http://www.otchy.net/js/twitterapi_0.9.2.jsより
f = document.createElement('form');
f.id = 'TwiterAPIForm';
f.method = 'POST';
f.target = 'TwiterAPIFrame';
f.setAttribute('accept-charset','UTF-8');//この行を追加
f.style.display = 'none';
var i = document.createElement('iframe');
i.name = 'TwiterAPIFrame';
f.appendChild(i);
document.body.appendChild(f);
i.contentWindow.name = i.name;
f.action = 'http://twitter.com/statuses/update.xml';
var h = document.createElement('input');
h.type = 'hidden';
h.name = 'status';
h.value = document.getElementById("status").value;
f.appendChild(h);
f.submit();
//-----------
txtBX.value="";
fakeTW.style.visibility='hidden';
sbmt.style.visibility='hidden';
return false;
}, false);
fakeTW.appendChild(sbmt);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment