By Chilla42o
—
Last update
Jul 17, 2009
—
Installed
263 times.
// ==UserScript==
// @name Tweetsymbols
// @namespace Chilla42o
// @description Easily insert special symbols in your tweets
// @include http://twitter.com/*
// @version 0.1
// ==/UserScript==
function TweetSymbols() {
var $ = unsafeWindow.$;
var that = this;
var symbols = {
black_sun_with_rays: '☀',
cloud: '☁',
umbrella: '☂',
snowman: '☃',
comet: '☄',
black_star: '★',
white_star: '☆',
lightning: '☇',
thunderstorm: '☈',
sun: '☉',
ascending_node: '☊',
descending_node: '☋',
conjunction: '☌',
opposition: '☍',
black_telephone: '☎',
white_telephone: '☏',
ballot_box: '☐',
ballot_box_with_check: '☑',
ballot_box_with_x: '☒',
saltire: '☓',
umbrella_with_rain_drops: '☔',
hot_beverage: '☕',
white_shogi_piece: '☖',
black_shogi_piece: '☗',
shamrock: '☘',
reversed_rotated_floral_heart_bullet: '☙',
black_left_pointing_index: '☚',
black_right_pointing_index: '☛',
white_left_pointing_index: '☜',
white_up_pointing_index: '☝',
white_right_pointing_index: '☞',
white_down_pointing_index: '☟',
skull_and_crossbones: '☠',
caution_sign: '☡',
radioactive_sign: '☢',
biohazard_sign: '☣',
caduceus: '☤',
ankh: '☥',
orthodox_cross: '☦',
chi_rho: '☧',
cross_of_lorraine: '☨',
cross_of_jerusalem: '☩',
star_and_crescent: '☪',
farsi: '☫',
adi_shakti: '☬',
hammer_and_sickle: '☭',
peace: '☮',
yin_yang: '☯',
wheel_of_dharma: '☸',
white_frowning_face: '☹',
white_smiling_face: '☺',
black_smiling_face: '☻',
white_sun_with_rays: '☼',
first_quarter_moon: '☽',
last_quarter_moon: '☾',
mercury: '☿',
female_sign: '♀',
earth: '♁',
male_sign: '♂',
jupiter: '♃',
saturn: '♄',
uranus: '♅',
neptune: '♆',
pluto: '♇',
aries: '♈',
taurus: '♉',
gemini: '♊',
cancer: '♋',
leo: '♌',
virgo: '♍',
libra: '♎',
scorpius: '♏',
sagittarius: '♐',
capricorn: '♑',
aquarius: '♒',
pisces: '♓',
white_chess_king: '♔',
white_chess_queen: '♕',
white_chess_rook: '♖',
white_chess_bishop: '♗',
white_chess_knight: '♘',
white_chess_pawn: '♙',
black_chess_king: '♚',
black_chess_queen: '♛',
black_chess_rook: '♜',
black_chess_bishop: '♝',
black_chess_knight: '♞',
black_chess_pawn: '♟',
black_spade_suit: '♠',
white_heart_suit: '♡',
white_diamond_suit: '♢',
black_club_suit: '♣',
white_spade_suit: '♤',
black_heart_suit: '♥',
black_diamond_suit: '♦',
white_club_suit: '♧',
hot_springs: '♨',
quarter_note: '♩',
eighth_note: '♪',
beamed_eighth_notes: '♫',
beamed_sixteenth_notes: '♬',
music_flat_sign: '♭',
music_natural_sign: '♮',
music_sharp_sign: '♯',
west_syriac_cross: '♰',
east_syriac_cross: '♱',
universal_recycling: '♲',
generic_recycling: '♺',
black_universal_recycling: '♻',
recycled_paper: '♼',
partially_recycled_paper: '♽',
permanent_paper_sign: '♾',
wheelchair: '♿',
};
this.symboltable = '<div id="tweetsymbols"><ol>';
for (symbolname in symbols) {
this.symboltable = this.symboltable + '<li><a id="'+symbolname+'" title="'+symbolname.replace(/_/g, ' ')+'">'+symbols[symbolname]+'</a></li>';
}
this.symboltable = this.symboltable + '</ol></div>';
$('head').append('<style type="text/css">'+
'div#tweetsymbols { position:absolute; display:none; z-index:999; margin: 15px 0 0 15px; text-align:left; background:white; border:1px solid #b5b5b5; width:288px; padding:3px; }'+
'div#tweetsymbols ol { list-style:none; font-size:18px; } '+
'div#tweetsymbols ol li { display:inline-block; width:24px; height:24px; }'+
'div#tweetsymbols ol li a { text-align:center; display:block; width:24px; height:24px; line-height:24px; cursor:pointer; }'+
'div#tweetsymbols ol li a:hover { background:#f7f7f7; text-decoration:none; }'+
'input#insert-symbol { width: 25px; border:1px solid; border-color:#ebebeb #ebebeb #d9d9d9 #d9d9d9; background-position:center center; }'+
'div#currently { width:335px; }'+
'</style>');
this.insertsymbol = function(which) {
var field = document.getElementById('status');
field.focus();
var scrollTop = field.scrollTop,
scrollLeft = field.scrollLeft,
selStart = field.selectionStart,
selEnd = field.selectionEnd;
field.value = field.value.substring(0, selStart) + symbols[which] + field.value.substring(selEnd);
field.scrollTop = scrollTop;
field.scrollLeft = scrollLeft;
field.selectionEnd = selStart + 1;
field.selectionStart = field.selectionEnd;
};
$('div.info div.status-btn').prepend(this.symboltable).append('<input value="☆" id="insert-symbol" class="round-btn" tabindex="3" type="button">');
$('input#insert-symbol').click(function(e) {
$('div#tweetsymbols').show();
});
$('div#tweetsymbols a').click(function() {
that.insertsymbol($(this).attr('id'));
$('strong#status-field-char-counter').html(140-$('textarea#status').val().length);
//uncomment following line if you want the symbol-table to hide after clicking on a symbol
//$('div#tweetsymbols').hide();
})
$('div#tweetsymbols').hover(null, function() {
$(this).hide();
});
}
new TweetSymbols();