My favorites | Sign in
Project Logo
yjl
                
Repository:
Checkout | Browse | Changes | Clones |
 
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Copyright (c) 2009, Yu-Jie Lin
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY Yu-Jie Lin ''AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Yu-Jie Lin BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
Bookmarklet URI:
javascript:void((function(){$.getScript('http://yjl.googlecode.com/hg/JavaScript/TwitRT.js')})())

Author : Yu-Jie Lin
Website : http://livibetter.mp/
Demo page:
*/
// Make each status holder taller
$('ol.statuses > li').css('padding-bottom', '1.6em');

var eles = $('.status > .actions > div');
if (eles.length == 0)
// Search results do not have a div wrapper
eles = $('.status > .actions')
eles.each(function(){
var ele = $(this);
// Make sure this script does not add more than one retweet button to each status
if (ele.find('.retweet').length == 0)
var rt_ele = $('<a class="retweet" title="retweet this tweet" href="#"><img src="http://yjl.googlecode.com/hg/JavaScript/TwitRT.png"/></a>').click(function(){
var ele = $(this);
var par = ele.parents('.hentry.status');
var rt_status = 'RT @'
+ par.find('.screen-name').text()
// Profile page
+ $('#profile .profile-user div.screen-name').text()
// Show page
+ $('#show .status .user-info .screen-name').text()
+ ' '
// Home or profile pages
+ par.find('.entry-content').text()
// Search page
+ par.find('.msgtxt').text();
var ele_status = $('#status');
if (ele_status.length == 0) {
// This page has NO status input box such as someone's profile page
window.open('http://twitter.com/?status=' + encodeURIComponent(rt_status));
}
else {
// This page has status input box such as home page
ele_status.val(rt_status);
}
});
ele.append(rt_ele);
if ($('#show').length == 0) {
$(this).find('.retweet').hide();
ele.parents('li').hover(function (){
$(this).find('.retweet').show();
}, function (){
$(this).find('.retweet').hide();
});
}

});
Show details Hide details

Change log

732d219791 by Yu-Jie Lin <livibetter> on Oct 23, 2009   Diff
TwitRT: fixed again
Go to: 
Sign in to write a code review

Older revisions

c8b906dbe4 by Yu-Jie Lin <livibetter> on Oct 19, 2009   Diff
TwitRT: Added retweet button to status
page
8689d343b7 by Yu-Jie Lin <livibetter> on Oct 17, 2009   Diff
TwitRT: Fixed position, show/hide
4700ec659e by Yu-Jie Lin <livibetter> on Oct 13, 2009   Diff
TwitRT: fixed on search results again
All revisions of this file

File info

Size: 3039 bytes, 77 lines
Hosted by Google Code