NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Devrant - Quick Emoji // @namespace PXgamer // @version 0.2 // @description Something // @author PXgamer // @include *devrant.io/* // @grant none // ==/UserScript== /*jshint multistr: true */ (function() { 'use strict'; $('head').append('<style>.quickEmoji{cursor:pointer}.emojibar{background-color:#aaaab8;color:#fff;padding:4px 14px;font-size:14px;border-bottom:0.2em solid grey}</style>'); jQuery.fn.extend({ insertAtCaret: function(myValue){ return this.each(function(i) { if (document.selection) { //For browsers like Internet Explorer this.focus(); sel = document.selection.createRange(); sel.text = myValue; this.focus(); } else if (this.selectionStart || this.selectionStart == '0') { //For browsers like Firefox and Webkit based var startPos = this.selectionStart; var endPos = this.selectionEnd; var scrollTop = this.scrollTop; this.value = this.value.substring(0, startPos)+myValue+this.value.substring(endPos,this.value.length); this.focus(); this.selectionStart = startPos + myValue.length; this.selectionEnd = startPos + myValue.length; this.scrollTop = scrollTop; } else { this.value += myValue; this.focus(); } }); } }); $('.post-rant-bottom').before(` <div class="emojibar"> <span class="quickEmoji" title="Grinning">đ</span> <span class="quickEmoji" title="Joy">đ</span> <span class="quickEmoji" title="Smile">đ</span> <span class="quickEmoji" title="Rofl">đ¤Ŗ</span> <span class="quickEmoji" title="Laugh">đ</span> <span class="quickEmoji" title="Wink">đ</span> <span class="quickEmoji" title="Neutral">đ</span> <span class="quickEmoji" title="Smiley eyes">đ</span> <span class="quickEmoji" title="Sad">âšī¸</span> <span class="quickEmoji" title="Weary">đŠ</span> <span class="quickEmoji" title="Love">đ</span> <span class="quickEmoji" title="Cool">đ</span> </div> `); $('.quickEmoji').click(function(){ var emoji = $(this).text(); $('#rant').insertAtCaret(emoji); }); })();