/* * Twittperator * Vimperator用Twitterクライアント * * 最初にPINコードを取得し設定する必要があります。 * :tw -getPIN * 実行すると新規タブに本アプリケーションを許可するかを問うページが開かれます * 許可をすると、PINコード(数値)が表示されるのでコピーしてください。 * * :tw -setPIN コピーしたPINコード * で初期設定完了です。 * * コマンド * :tw[ittperator] ~ * * :tw -getPIN * :tw -setPIN {PINcode} * 初期設定時のみのコマンド * * :tw[!] * タイムライン表示。!が付くと強制的に取得 * !が付いていない場合はキャッシュから表示(賞味期限が切れている場合は再取得) * * :tw ~ * ポスト * * @see http://twitter.com/oauth_clients/details/197565 */ // TwitterOauth for Greasemonkey function TwitterOauth() { this.initialize.apply(this, arguments); } // OAuth {{{ TwitterOauth.prototype = (function() { // {{{2 oauth.js /* OAuth.js SHA-1.js TwitterOauth for Greasemonkey */ /* * Copyright 2008 Netflix, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* Here's some JavaScript software for implementing OAuth. This isn't as useful as you might hope. OAuth is based around allowing tools and websites to talk to each other. However, JavaScript running in web browsers is hampered by security restrictions that prevent code running on one website from accessing data stored or served on another. Before you start hacking, make sure you understand the limitations posed by cross-domain XMLHttpRequest. On the bright side, some platforms use JavaScript as their language, but enable the programmer to access other web sites. Examples include Google Gadgets, and Microsoft Vista Sidebar. For those platforms, this library should come in handy. */ // The HMAC-SHA1 signature method calls b64_hmac_sha1, defined by // http://pajhome.org.uk/crypt/md5/sha1.js /* An OAuth message is represented as an object like this: {method: "GET", action: "http://server.com/path", parameters: ...} The parameters may be either a map {name: value, name2: value2} or an Array of name-value pairs [[name, value], [name2, value2]]. The latter representation is more powerful: it supports parameters in a specific sequence, or several parameters with the same name; for example [["a", 1], ["b", 2], ["a", 3]]. Parameter names and values are NOT percent-encoded in an object. They must be encoded before transmission and decoded after reception. For example, this message object: {method: "GET", action: "http://server/path", parameters: {p: "x y"}} ... can be transmitted as an HTTP request that begins: GET /path?p=x%20y HTTP/1.0 (This isn't a valid OAuth request, since it lacks a signature etc.) Note that the object "x y" is transmitted as x%20y. To encode parameters, you can call OAuth.addToURL, OAuth.formEncode or OAuth.getAuthorization. This message object model harmonizes with the browser object model for input elements of an form, whose value property isn't percent encoded. The browser encodes each value before transmitting it. For example, see consumer.setInputs in example/consumer.js. */ /* This script needs to know what time it is. By default, it uses the local clock (new Date), which is apt to be inaccurate in browsers. To do better, you can load this script from a URL whose query string contains an oauth_timestamp parameter, whose value is a current Unix timestamp. For example, when generating the enclosing document using PHP: