motemen (owner)

Revisions

gist: 43648 Download_button fork
public
Public Clone URL: git://gist.github.com/43648.git
JavaScript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// ==UserScript==
// @name Kore Yoyaku Shita
// @namespace http://twitter.com/motemen
// @include http://www.amazon.co.jp/*-22*
// ==/UserScript==
 
var ID_MAPPING = {
    nifuba: 'fuba',
    harsch: 'harsch',
    tokyoenvious: 'motemen'
};
 
if (location.href.match(/(\w+)-22/) && RegExp.$1 in ID_MAPPING) {
    var twitter_id = ID_MAPPING[RegExp.$1];
    var button = document.getElementById('addToCartSpan').getElementsByTagName('input')[0];
    if (button.alt == 'この商品を今日予約注文する') {
        button.addEventListener('click', function (e) {
            GM_xmlhttpRequest({
                method: 'POST',
                url: 'http://twitter.com/statuses/update.json',
                headers: { 'Content-type': 'application/x-www-form-urlencoded' },
                data: 'status=' + encodeURIComponent('@' + twitter_id + ' これ予約した http://www.amazon.co.jp/exec/obidos/ASIN/' + unsafeWindow.asin + '/tokyoenvious-22')
            });
        }, true);
    }
}