Code: Select all
/*Copyright (c) 2006, Bruce WeirdanAll rights reserved. Redistribution and use in source and binary forms,with or without modification, are permitted providedthat the following conditions are met: * Redistributions of source code must retain theabove copyright notice, this list of conditions andthe following disclaimer. * Redistributions in binary form must reproducethe above copyright notice, this list of conditionsand the following disclaimer in the documentationand/or other materials provided with the distribution. * The name of the copyright holder may NOT be usedto endorse or promote products derived from thissoftware without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ANDCONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIEDWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR APARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALLTHE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANYDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ORCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OFUSE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHERIN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDINGNEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THEUSE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF SUCH DAMAGE.*/ // ==UserScript==// @name PHPBB Fix Smilies// @namespace tag:weirdan@gmail.com,2005:greasemonkey#phpbb.fixsmilies// @description fix smilies for phpbb in Fx// @include *posting.php?mode=*// @exclude *posting.php?mode=topicreview*// ==/UserScript== function storeGMCaret() { textarea.setAttribute('GM_caretPos', textarea.selectionStart);};var textarea = document.getElementsByName('message')[0]; textarea.addEventListener('click', storeGMCaret, false); textarea.addEventListener('keyup', storeGMCaret, false); textarea.addEventListener('select', storeGMCaret, false); unsafeWindow.emoticon = function(text) { textarea.value = textarea.value.substr(0, textarea.getAttribute('GM_caretPos')) + text + textarea.value.substr(textarea.getAttribute('GM_caretPos')); textarea.selectionStart = textarea.selectionEnd = (parseInt(textarea.getAttribute('GM_caretPos')) + text.length); storeGMCaret(); textarea.focus();}