From 8034ba15e4325c326720ff16e7a602e2c995e7a0 Mon Sep 17 00:00:00 2001 From: teramako Date: Fri, 2 Jul 2010 14:55:17 +0000 Subject: first release git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@37887 d0d07461-0603-4401-acd4-de1884942a52 --- twittperator.js | 1277 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1277 insertions(+) create mode 100755 twittperator.js (limited to 'twittperator.js') diff --git a/twittperator.js b/twittperator.js new file mode 100755 index 0000000..1ab1d4e --- /dev/null +++ b/twittperator.js @@ -0,0 +1,1277 @@ +var GM_OAuth = <>; + +// TwitterOauth for Greasemonkey +function TwitterOauth(){ + this.initialize.apply(this, arguments); +} + +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: + +